我的应用程序包括主消息循环(GUI)和线程(Task.Factory).
在线程中我用一些第三方应用程序调用 var p = new Process();
但是当我Application.Exit();在消息循环中调用时- 我可以看到在线程中启动的进程仍然在内存中并且正在执行.
所以问题是 - 如何Application.Exit();在调用之后立即杀死所有线程和进程?
UPD:
旧:
p.WaitForExit();
Run Code Online (Sandbox Code Playgroud)
新:
while (!p.WaitForExit(1000))
{
if (FlagToExit)
{
p.Kill();
return;
}
}
Run Code Online (Sandbox Code Playgroud) 我正在添加按钮以形成循环,我注意到添加单击事件处理程序会减慢应用程序的速度.后来我尝试鼠标点击事件而不是单击事件,它立即工作.
此截图显示了我的测试结果:
源代码:http://pastebin.com/qVewNm1u
1000事件处理程序的结果:
单击:2892ms MouseClick:1ms
我无法弄清楚为什么Click事件很慢.
编辑:如果我将构建平台目标更改为x64或任何CPU,结果更改:单击:5,MouseClick:9看起来像x86平台目标导致此问题但仍然x64结果与x86 MouseClick时间(1ms)相比也不太好.
Edit2:我改变了截图,现在它会显示更好的结果.
编辑3:https://connect.microsoft.com/VisualStudio/feedback/details/597039/winforms-click-event-slower-than-the-mouseclick-event
我有一个2d相机与这个翻译矩阵:
Transform = Matrix.CreateTranslation(new Vector3(-Position.X, -Position.Y, 0)) *
Matrix.CreateRotationZ(Rotation) *
Matrix.CreateScale(new Vector3(Scale, Scale, 0)) *
Matrix.CreateTranslation(new Vector3((GraphicsDevice.Viewport.Width * 0.5f), (GraphicsDevice.Viewport.Height * 0.5f), 0));
Run Code Online (Sandbox Code Playgroud)
适用于旋转/缩放,其中原点是相机的中心.
现在我想在世界上获得鼠标坐标.
我尝试使用逆变换,但这只会导致NaN错误.我猜我需要为鼠标坐标设置另一个转换矩阵,与当前的坐标相反,但我无法弄清楚它是如何设置的
我有这个,
MousePosition = new Vector2((Mouse.GetState().X - DrawTransform.Translation.X)*(1/Gamecode.Camera1.Scale),(Mouse.GetState().Y - DrawTransform.Translation.Y)*(1/Gamecode.Camera1.Scale));
但这没有考虑到轮换
我真的不认为这是一个精确的问题,答案应该是0.226左右.这是确切的代码:
val = I(i,j)
bucketSize
pos = val / bucketSize
Run Code Online (Sandbox Code Playgroud)
I只是一个我从中获取价值的矩阵.这是MATLAB的输出:
val =
29
bucketSize =
128
pos =
0
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
我正在使用一个AlarmManager触发广播信号的意图.以下是我的代码:
AlarmManager mgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
Intent i = new Intent(this, Wakeup.class);
try
{
PendingIntent pi = PendingIntent.getBroadcast(this, 0, i, 0);
Long elapsed += // sleep time;
mgr.set(AlarmManager.RTC_WAKEUP, elapsed, pi);
}
catch(Exception r)
{
Log.v(TAG, "RunTimeException: " + r);
}
Run Code Online (Sandbox Code Playgroud)
我从一个调用这个代码Activity,所以我不知道如何得到以下错误...
ERROR/AndroidRuntime(7557): java.lang.RuntimeException: Unable to start receiver com.wcc.Wakeup: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
Run Code Online (Sandbox Code Playgroud) 我需要解析一个大小可能很多gbs的文件.我想在C中这样做.任何人都可以建议任何方法来实现这一目标吗?
我需要打开和解析的文件是我从mac的硬盘驱动器获取的硬盘驱动器转储.但是,我打算在64位Ubuntu 10.04中运行我的程序.同时考虑到大文件大小,方法越优化越好.
我正在尝试在我的工作中为我的同事和我使用的所有代码(主要是C,汇编程序,批处理基础)设置一个存储库.我知道有关存储库的一些事情,但无法正确判断哪些是好的.我对它们没有经验,但到目前为止,Apache Subversion和Python的repo看起来还不错.还有其他好的吗?易于使用和设置?
我想使用正则表达式查看文本是否已经在文件中。
# file.txt
Hi my name is Foo
and I live in Bar
and I have three children.
Run Code Online (Sandbox Code Playgroud)
我想看看文字是否:
Hi my name is Foo
and I live in Bar
Run Code Online (Sandbox Code Playgroud)
在这个文件中。
如何将它与正则表达式匹配?
我正在尝试使用MSBuild的复制任务递归地将文件夹复制到多个目标文件夹.我看到以下问题给了我一个良好的开端,但我必须遗漏一些东西:
我的构建文件中的代码段如下:
<ItemGroup>
<DeployPath Include="\\server1\path" />
<DeployPath Include="\\server2\path" />
</Item Group>
<Target Name="Deploy">
<Message Text="%(DeployPath.Identity)" />
<Copy SourceFiles="@(ItemsToCopy)" DestinationFolder="%(DeployPath.Identity)\%(RecursiveDir)" />
</Target>
Run Code Online (Sandbox Code Playgroud)
当我运行它时,正如我所料,"消息"任务会吐出2行:
\\server1\path
\\server2\path
Run Code Online (Sandbox Code Playgroud)
问题是,"复制"任务似乎只运行一次,并将文件复制到当前硬盘驱动器的根目录而不是指定的网络路径:
复制到C:\file1.txt而不是\\server1\path\file1.txt
我对MSBuild很新,所以我觉得我在这里缺少一些非常基本的东西.
任何帮助将不胜感激.
我是Django的初学者,我在使用pip安装django-basic-apps时遇到了麻烦.
如果我这样做......
$ cat requirements.txt
git+git://github.com/nathanborror/django-basic-apps.git
$ pip install -r requirements.txt
Run Code Online (Sandbox Code Playgroud)
我最终lib/python2.6/site-packages/basic/blog没有模板目录.
如果我这样做......
git clone http://github.com/nathanborror/django-basic-apps.git
Run Code Online (Sandbox Code Playgroud)
我最终得到了一份basic/blogDOES有一个模板目录的副本.
我怀疑django-basic-apps或pip使它无法通过pip安装.我想,也许阅读django-basic-apps的setup.py将导致我的答案,但我无法看到它.
(我应该补充一点,如果我不使用pip安装,我就可以django-basic-apps正常工作了.)
.net ×2
c# ×2
2d ×1
alarmmanager ×1
android ×1
c ×1
camera ×1
click ×1
division ×1
django ×1
events ×1
large-files ×1
matlab ×1
msbuild ×1
msbuild-task ×1
pip ×1
process ×1
python ×1
regex ×1
repository ×1
ruby ×1
translation ×1
winforms ×1
xna ×1