以下面的课程为例.
public class A
{
// ...
void Foo(S myStruct){...}
}
public class B
{
public A test;
// ...
void Bar()
{
S myStruct = new S();
test.Foo(myStruct);
}
}
Run Code Online (Sandbox Code Playgroud)
现在,我希望方法调用test.Foo(myStruct)是一个异步调用('fire-and-forget').条形方法需要尽快返回.代理,BeginInvoke,EndInvoke,ThreadPool等文档不能帮助我找到解决方案.
这是有效的解决方案吗?
// Is using the `EndInvoke` method as the callback delegate valid?
foo.BeginInvoke(myStruct, foo.EndInvoke, null);
Run Code Online (Sandbox Code Playgroud)