【发布时间】:2011-09-20 22:52:18
【问题描述】:
以以下类为例。
public class A
{
// ...
void Foo(S myStruct){...}
}
public class B
{
public A test;
// ...
void Bar()
{
S myStruct = new S();
test.Foo(myStruct);
}
}
现在,我希望方法调用 test.Foo(myStruct) 是一个异步调用(“即发即弃”)。 bar-method 需要尽快返回。关于委托、BeginInvoke、EndInvoke、ThreadPool 等的文档并没有帮助我找到解决方案。
这是一个有效的解决方案吗?
// Is using the `EndInvoke` method as the callback delegate valid?
foo.BeginInvoke(myStruct, foo.EndInvoke, null);
【问题讨论】:
标签: c# asynchronous delegates action