我有一个功能
public void ShowAllFly()
{
cbFly.Items.Clear();
cbFly.Items.Add("Uçu? Seçiniz...");
dsFlyTableAdapters.tblFlyTableAdapter _t=new KTHY.dsFlyTableAdapters.tblFlyTableAdapter();
dsFly _mds = new dsFly();
_mds.EnforceConstraints = false;
dsFly.tblFlyDataTable _m = _mds.tblFly;
_t.Fill(_m);
foreach (DataRow _row in _m.Rows)
{
cbFly.Items.Add(_row["FlyID"].ToString()+"-"+_row["FlyName"].ToString() + "-" + _row["FlyDirection"].ToString() + "-" + _row["FlyDateTime"].ToString());
}
_Thread.Abort();
timer1.Enabled = false;
WaitPanel.Visible = false;
}
Run Code Online (Sandbox Code Playgroud)
在Form_Load函数中像这样;
{
_Thread = new System.Threading.Thread(new System.Threading.ThreadStart(ShowAllFly));
_Thread.Start();
_Thread.Priority = System.Threading.ThreadPriority.Normal;
}
Run Code Online (Sandbox Code Playgroud)
但是当我跑的时候;
在ShowAllFly函数中
cbFly.Items.Clear(); ---- HERE Gives ERROR LIKE Control.Invoke must be used to interact with controls created on a separate …Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个函数来自动进行方差分析,其中一部分涉及进行一些进一步的计算.我一直在使用的方法不是很健壮,如果变量名称发生变化则会停止工作.
对于这个虚拟数据
> dput(assayvar,"")
structure(list(Run = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 3L,
3L, 3L, 4L, 4L, 4L), .rk.invalid.fields = list(), .Label = c("1",
"2", "3", "4"), class = "factor"), Actual = c(246.3, 253.6, 247.6,
249, 249, 251.3, 254.9, 254.1, 253.2, 250, 248.9, 250.3)), .Names = c("Run",
"Actual"), row.names = c(NA, 12L), class = "data.frame")
> assayaov<-aov(Actual~Run+Error(Run),data=assayvar)
> str(summary(assayaov))
List of 2
$ Error: Run :List of 1
..$ :Classes ‘anova’ and 'data.frame': 1 obs. of 3 variables:
.. ..$ …Run Code Online (Sandbox Code Playgroud) 我需要使用bash shell"内部"C#程序.我想模仿用户在交互模式下键入并运行cygwin命令.
我创建了一个运行bash和重定向stdin,stout和std错误的进程,但我可以; t t t to to work附加是一个示例代码,它启动bash进程并重定向输入/输出.
问题是我没有tty设备.如果我尝试运行tty命令或stty命令我收到错误响应
tty - not a tty
stty - Inappropriate ioctl for device
Run Code Online (Sandbox Code Playgroud)
我认为这是由于 psi.UseShellExecute = false;
我需要运行cygwin并使用stty -echo禁用echo但是要做到这一点我需要一个tty设备.如何用tty设备创建一个cygwin bash shell并重定向stdin,out和error?
1)缺少什么?
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
namespace shartCygwin
{
class Program
{
private static Queue<string> ResponseQueue = null;
private static ManualResetEvent ResponseEvent = null;
static void Main(string[] args)
{
ResponseQueue = new Queue<string>();
ResponseEvent = new ManualResetEvent(false);
Process bashProcess = new Process();
bashProcess.StartInfo.FileName = …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Windows SDK中的mt.exe将清单添加到没有的清单,使用以下命令行:
C:\winsdk61>mt.exe -nologo -manifest "r:\shared\hl.exe.manifest" -updateresource:"r:\shared\hl33m.exe;#1"
Run Code Online (Sandbox Code Playgroud)
不幸的是,当我这样做时,我收到此错误:
mt.exe : general error c101008c: Failed to read the manifest from
the resource of file "r:\shared\hl33m.exe". The specified resource
type cannot be found in the image file.
Run Code Online (Sandbox Code Playgroud)
当然在文件中找不到资源 - 文件没有清单,这就是我想添加一个的原因.
如何将清单附加到可执行文件?这不应该简单吗?
我想要实现的是通过字符串值对对象的集合进行排序.但是,使用collator以依赖于语言环境的方式.由于性能原因,我不想使用Collator compare()方法(如下面的代码中)而不是CollationKey类,因为java API声明使用CollationKey要快得多.
但是如何使用CollationKey实现compareTo()方法?据我所知,如果我将使用CollationKey,我必须自己完全编写所有的比较方法.所以我甚至不再能够使用Collections.sort()方法......我非常感谢一个易于理解的示例,以及使用CollationKey对Person对象的Collection进行排序的最有效实现.
谢谢!
public class Person implements Comparable<Person> {
String lastname;
public int compareTo(Person person) {
//This works but it is not the best implementation for a good performance
Collator instance = Collator.getInstance(Locale.ITALY);
return instance.compare(lastname, person.lastname);
}
}
...
ArrayList list = new ArrayList();
Person person1 = new Person("foo");
list.add(person1);
Person person2 = new Person("bar");
list.add(person2);
Collections.sort(list);
...
Run Code Online (Sandbox Code Playgroud) 我使用Json.net问题和答案查看了这个解析JSON,它接近我需要的东西.关键区别是我需要解析每个记录形成一行或多行的x,y对数组.这是我输入的一个例子
{
"displayFieldName" : "FACILITYID",
"fieldAliases" : {
"FACILITYID" : "Facility Identifier",
},
"geometryType" : "esriGeometryPolyline",
"spatialReference" : {
"wkid" : 4326
},
"features" : [
{
"attributes" : {
"FACILITYID" : "",
"OBJECTID" : 1,
},
"geometry" :
{
"paths" :
[
[
[-80.3538239379999, 27.386884271],
[-80.3538100319999, 27.3868901900001],
[-80.3538157239999, 27.3869008510001]
]
]
}
},
{
"attributes" : {
"FACILITYID" : "",
"OBJECTID" : 2,
},
"geometry" :
{
"paths" :
[
[
[-80.3538239379999, 27.386884271],
[-80.3538295849999, 27.3868948420001] …Run Code Online (Sandbox Code Playgroud) 这是有问题的功能.它计算p1和p2的Pearson相关系数,它应该是介于-1和1之间的数字.
当我将它与真实用户数据一起使用时,它有时会返回一个大于1的数字,如下例所示:
def sim_pearson(prefs,p1,p2):
si={}
for item in prefs[p1]:
if item in prefs[p2]: si[item]=1
if len(si)==0: return 0
n=len(si)
sum1=sum([prefs[p1][it] for it in si])
sum2=sum([prefs[p2][it] for it in si])
sum1Sq=sum([pow(prefs[p1][it],2) for it in si])
sum2Sq=sum([pow(prefs[p2][it],2) for it in si])
pSum=sum([prefs[p1][it]*prefs[p2][it] for it in si])
num=pSum-(sum1*sum2/n)
den=sqrt((sum1Sq-pow(sum1,2)/n)*(sum2Sq-pow(sum2,2)/n))
if den==0: return 0
r=num/den
return r
critics = {
'user1':{
'item1': 3,
'item2': 5,
'item3': 5,
},
'user2':{
'item1': 4,
'item2': 5,
'item3': 5,
}
}
print sim_pearson(critics, 'user1', 'user2', )
1.15470053838
Run Code Online (Sandbox Code Playgroud) 当我运行我的代码时,它总是停在for循环并跳过它.
public void assignCell()
{
Prisoner prisoner = prisoners.get(id-1);
for(Cell cell : cells)
if(cell.isAvailable())
{
cell.allocate(prisoner);
String bunk = null;
if(cell.isEven())
{
bunk = "top bunk of cell";
}
else
{
bunk = "only bunk of cell";
}
System.out.println("\t\t" + prisoner.nameToString() + " is in the " + bunk + cell.toString());
}
}
Run Code Online (Sandbox Code Playgroud)
我怎么能解决这个问题呢?
是否有一种简单的方法可以在WPF中的标题页的内部和右侧定位另一个控件(即按钮)?
在网络中,我会使用浮点或绝对定位来完成此任务.
这张照片中的红线是我想要的: WPF标签旁边的控件http://www.jonkragh.com/images/text-next-to-tabs.png
谢谢!乔恩