相关疑难解决方法(0)

没有EndInvoke的C#异步调用?

以下面的课程为例.

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)

c# delegates action asynchronous

10
推荐指数
1
解决办法
9993
查看次数

标签 统计

action ×1

asynchronous ×1

c# ×1

delegates ×1