有谁知道如何将多个参数传递给Thread.Start例程?
我想扩展类,但C#Thread类是密封的.
以下是我认为代码的样子:
...
Thread standardTCPServerThread = new Thread(startSocketServerAsThread);
standardServerThread.Start( orchestrator, initializeMemberBalance, arg, 60000);
...
}
static void startSocketServerAsThread(ServiceOrchestrator orchestrator, List<int> memberBalances, string arg, int port)
{
startSocketServer(orchestrator, memberBalances, arg, port);
}
Run Code Online (Sandbox Code Playgroud)
顺便说一下,我用不同的协调器,天平和端口启动了许多线程.请考虑线程安全.
我已尝试过网上的所有建议,但无济于事.
我根据这些说明编写了一个控制台应用程序:http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spcontenttypecollection.delete.aspx
"Usages.Count"是= 0.但是,当它试图删除内容类型时,我得到一个异常:
"内容类型正在使用中."
这是一个全新的(开发)安装.我在SP Designer中创建了一个测试站点,创建了一个内容类型,然后创建了一个列表.然后,我删除了列表,将其从回收站中删除,并尝试删除内容类型......呃.
我有一个需要在Windows 2000上运行的应用程序.我还想使用Visual Studio 2010(主要是因为auto关键字定义的更改).但是,我有点绑定,因为我需要应用程序能够在较旧的操作系统上运行,即:
Visual Studio 2010的运行时库依赖EncodePointer / DecodePointer于Windows XP SP2中引入的API.
如果可以使用备用运行时库,那么这会破坏依赖于VS2010中添加的C++ 0x功能的代码std::regex吗?
当我对dos执行以下命令时,它将正常工作
ffmpeg -f image2 -i frame%d.jpg -vcodec mpeg4 -b 800k video.avi
Run Code Online (Sandbox Code Playgroud)
当我尝试在c#中使用流程类而没有参数时,它会在控制台窗口中加载ffmpeg,然后像往常一样消失.但是,当我尝试使用上面的参数时,格式完全相同......它不起作用!ffmpeg仍然加载,但是由于控制台窗口关闭如此之快,我无法确定错误是什么:/
Process ffmpeg = new Process();
ffmpeg.StartInfo.FileName = path + "//" + "ffmpeg.exe";
ffmpeg.StartInfo.Arguments = " -f image2 -i frame%d.jpg -vcodec mpeg4 -b 800k video.avi";
ffmpeg.Start();
Run Code Online (Sandbox Code Playgroud)
谁知道为什么会这样?为什么命令可以从dos工作,然后使用c#无法工作,即使参数完全相同?我之前使用过这种方法很多东西,从来没有遇到过这种情况.
以这一行为例:
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
</configuration>
Run Code Online (Sandbox Code Playgroud)
一些简短的研究告诉我,不一定必须在该URL上托管.因此,如果它只是对本地程序集中包含的命名空间的引用,为什么要使用URL而不是像.NET(System.Data)通常使用的那些常规命名空间?
据我了解,C#的foreach迭代变量是不可变的.
这意味着我不能像这样修改迭代器:
foreach (Position Location in Map)
{
//We want to fudge the position to hide the exact coordinates
Location = Location + Random(); //Compiler Error
Plot(Location);
}
Run Code Online (Sandbox Code Playgroud)
我无法直接修改迭代器变量,而是必须使用for循环
for (int i = 0; i < Map.Count; i++)
{
Position Location = Map[i];
Location = Location + Random();
Plot(Location);
i = Location;
}
Run Code Online (Sandbox Code Playgroud)
来自C++背景,我认为foreach是for循环的替代品.但是由于上述限制,我通常会回退使用for循环.
我很好奇,使迭代器不可变的原理是什么?
编辑:
这个问题更多的是一个好奇的问题,而不是一个编码问题.我很欣赏编码答案,但我不能将它们标记为答案.
此外,上面的例子过于简化了.这是我想要做的C++示例:
// The game's rules:
// - The "Laser Of Death (tm)" moves around the game board from the
// start area (index …Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个获取当前日期和时间的cmd脚本,并将其格式化为sqlserver可以将其作为输入的方式datetime.
到目前为止,我有:
@echo off
for /F "tokens=1-4 delims=/ " %%i in ('date /t') do (
set dow=%%i
set mon=%%j
set day=%%k
set yr=%%l
set mydate=%%j/%%k/%%l
)
Run Code Online (Sandbox Code Playgroud)
这打印出10/22/2010
我无法弄清楚如何将时间变成可用的格式.我尝试过time /t,但它只给出了小时和分钟,我也需要秒.
我需要一个像这样的配置部分:
<myConfig>
<mySubConfig1>
<mySubSubConfig1 keyAttribute="value1">
<mySubSubConfig1Element keyAttribute="value1"/>
<mySubSubConfig1Element keyAttribute="value2"/>
</mySubSubConfig1>
<mySubSubConfig1 keyAttribute="value2">
<mySubSubConfig1Element keyAttribute="value1"/>
</mySubSubConfig1>
</mySubConfig1>
<mySubConfig2>
<mySubSubConfig2 keyAttribute="value1">
<mySubSubConfig2Element keyAttribute="value1"/>
<mySubSubConfig2Element keyAttribute="value2"/>
</mySubSubConfig2>
<mySubSubConfig2 keyAttribute="value2">
<mySubSubConfig2Element keyAttribute="value1"/>
</mySubSubConfig2>
</mySubConfig2>
<mySubConfig3>
<mySubSubConfig3 keyAttribute="value1">
<mySubSubConfig3Element keyAttribute="value1"/>
<mySubSubConfig3Element keyAttribute="value2"/>
</mySubSubConfig3>
<mySubSubConfig3 keyAttribute="value2">
<mySubSubConfig3Element keyAttribute="value1"/>
</mySubSubConfig3>
</mySubConfig3>
</myConfig>
Run Code Online (Sandbox Code Playgroud)
我还没有找到允许使用旧IConfigurationSectionHandler界面的魔法.有谁知道怎么做?
如果myConfig和mySubConfign是ConfigurationSectionGroup或是,我可以ConfigurationSection.
此外,如果重要,将从web.config中使用它.
.net ×5
c# ×3
.net-2.0 ×1
batch-file ×1
c++ ×1
cmd ×1
collections ×1
command-line ×1
content-type ×1
deployment ×1
parameters ×1
process ×1
url ×1
vb.net ×1
xml ×1