C# Asynchronous call without EndInvoke?

前端 未结 4 1288
野趣味
野趣味 2020-12-10 05:38

Take the following classes as an example.

public class A
{
   // ...
   void Foo(S myStruct){...}
}

public class B
{
   public A test;
   // ...
   void Bar         


        
4条回答
  •  抹茶落季
    2020-12-10 06:01

    You can use the Callback model explained @ What is AsyncCallback?

    That way your EndInvoke will not be in bar(), but in a separate callback method.

    In the example, the EndRead (corresponding to EndInvoke is in the callback method called CompleteRead rather than the calling method TestCallbackAPM corresponding to bar)

提交回复
热议问题