异步处理问题 [英] Asynchronous Process Question

查看:68
本文介绍了异步处理问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个需要一段时间才能运行的进程,所以我让它以异步方式运行

,以便用户可以继续工作。我的问题是,如果用户在调用回调方法之前更改搜索参数,那么我想要杀死进程。关于如何做到这一点的任何想法,或者甚至是否b / b $ b重要吗?我不知道是否打电话给asynch进程新的时间会杀死之前的




感谢您的帮助。

Susan

I have a process that takes a while to run so I have it running
asynchronously so that the user can continue working. My question is that I
want to killl the process if the user changes the search parameters before
the callback method is called. Any ideas of how to do this or if it even
matters? I did not know if calling the asynch process a new time kills the
previous one or not.

Thank you for your help.
Susan

推荐答案



Susan写道:

Susan wrote:

我有一个需要一段时间才能运行的进程,所以我让它以异步方式运行

,以便用户可以继续工作。我的问题是,如果用户在调用回调方法之前更改搜索参数,那么我想要杀死进程。关于如何做到这一点的任何想法,或者甚至是否b / b $ b重要吗?我不知道是否打电话给asynch进程新的时间会杀死之前的




感谢您的帮助。

Susan
I have a process that takes a while to run so I have it running
asynchronously so that the user can continue working. My question is that I
want to killl the process if the user changes the search parameters before
the callback method is called. Any ideas of how to do this or if it even
matters? I did not know if calling the asynch process a new time kills the
previous one or not.

Thank you for your help.
Susan



嗨Susan,

你能发一些代码吗?看起来你可以使用你拥有的对象引用来杀死进程




static void Main(string [] args)

{

流程p =新流程();

p.StartInfo.FileName = @" C:\ WINDOWS \ system32 \\\ npp。 exe" ;;

p.Start();


Console.WriteLine(按输入以杀死进程);

Console.ReadLine();

p.Kill();

返回;

}


希望这有帮助,

约翰

Hi Susan,
Can you post some code? It seems like you can just kill the process
using the object reference that you have:

static void Main(string[] args)
{
Process p = new Process();
p.StartInfo.FileName = @"C:\WINDOWS\system32\notepad.exe";
p.Start();

Console.WriteLine("press enter to kill process");
Console.ReadLine();
p.Kill();
return;
}

Hope this helps,
John


你好苏珊,


理论上你可以潜入消息唱出正在执行的对象

异步调用哪里是取消位置

但实际上很难做到,你需要拦截来电,上下文

等等


standarc acyns处理程序类没有取消同步调用的功能


SI有一个需要一段时间的过程运行所以我让它运行

Sasynchronously,以便用户可以继续工作。我的问题是

如果用户在调用回调方法之前更改了搜索,我想要杀死进程

Sparameters。有关如何使用这些或者甚至是重要的任何想法吗?我不知道是否打电话给asynch

Sprocess新的时间会杀死前一个。

S>

感谢您的帮助。

SSusan

---

WBR,

Michael Nemtsev ::博客: http://spaces.msn.com/laflour


有时一个人仍然忠于一个事业,只因为它的对手不会因为b $ b不再是平淡无奇的。 (c)Friedrich Nietzsche
Hello Susan,

Theoretically you can dive into message sing objects that are performing
async calls where is the cancellation located
but practically it''s very hard to do, you need to intercept calls, context
and etc.

standarc acyns handler classes don''t have functionality to cancell async call

SI have a process that takes a while to run so I have it running
Sasynchronously so that the user can continue working. My question is
Sthat I want to killl the process if the user changes the search
Sparameters before the callback method is called. Any ideas of how to
Sdo this or if it even matters? I did not know if calling the asynch
Sprocess a new time kills the previous one or not.
S>
SThank you for your help.
SSusan
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche


我认为这不会起作用。这里的代码片段:

私人CountDelegate dDeleg;


private void GetResults()

{

/ *从数据库中获取实际结果,但数量有限(25美元/ b $ b页面)到

增加响应时间* /

if(_newQuery)

{

cDeleg = new CountDelegate(Count);

AsyncCallback cb = new AsyncCallback(CountCallback) ;

cDeleg.BeginInvoke(tgts,cb," countDelegate");

}

}


private void CountCallback(IAsyncResult ar)

{

cDeleg.EndInvoke(ar);

SetCount(); //只是让用户知道有多少结果的东西



}


我不知道是否有是一种强制结束调用的方法,即使

进程没有完成。我知道甚至没有取消,但是我希望

有一种方法来模拟一个......任何想法?


谢谢你,

Susan


" John Duval"写道:
I do not think that will work. Here''s code snippets:
private CountDelegate dDeleg;

private void GetResults ()
{
/*get the actual results from database, but in limited number (25 per
page) to
increase response time*/

if (_newQuery)
{
cDeleg = new CountDelegate(Count);
AsyncCallback cb = new AsyncCallback (CountCallback);
cDeleg.BeginInvoke (tgts, cb, "countDelegate");
}
}

private void CountCallback (IAsyncResult ar)
{
cDeleg.EndInvoke (ar);
SetCount(); //just something letting the user know how many results there
are
}

I didn''t know if there was a way to force the end invoke even though the
process is not completed. I know that there is not cancel even, but am hoping
there is a way to similate one... Any ideas?

Thank you,
Susan

"John Duval" wrote:

>

Susan写道:
>
Susan wrote:

我有一个需要一段时间才能运行的进程,所以我让它以异步方式运行
,以便用户可以继续工作。我的问题是,如果用户在调用回调方法之前更改搜索参数,那么我想要杀死进程。关于如何做到这一点的任何想法,或者甚至是否b / b $ b重要吗?我不知道是否打电话给asynch进程新的时间会杀死之前的




感谢您的帮助。

苏珊
I have a process that takes a while to run so I have it running
asynchronously so that the user can continue working. My question is that I
want to killl the process if the user changes the search parameters before
the callback method is called. Any ideas of how to do this or if it even
matters? I did not know if calling the asynch process a new time kills the
previous one or not.

Thank you for your help.
Susan



嗨苏珊,

你能发一些代码吗?看起来你可以使用你拥有的对象引用来杀死进程




static void Main(string [] args)

{

流程p =新流程();

p.StartInfo.FileName = @" C:\ WINDOWS \ system32 \\\ npp。 exe" ;;

p.Start();


Console.WriteLine(按输入以杀死进程);

Console.ReadLine();

p.Kill();

返回;

}


希望这有帮助,

John


Hi Susan,
Can you post some code? It seems like you can just kill the process
using the object reference that you have:

static void Main(string[] args)
{
Process p = new Process();
p.StartInfo.FileName = @"C:\WINDOWS\system32\notepad.exe";
p.Start();

Console.WriteLine("press enter to kill process");
Console.ReadLine();
p.Kill();
return;
}

Hope this helps,
John


这篇关于异步处理问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆