Too many arguments in BeginXXX for FromAsync?

后端 未结 3 1966
说谎
说谎 2021-02-13 05:12

I have an async method with the following signature:

IAsyncResult BeginGetMyNumber(string foo, string bar, string bat, int bam, AsyncCallback callback, object s         


        
3条回答
  •  再見小時候
    2021-02-13 05:31

    result = Task.Factory.FromAsync(
      (callback, state) => instance.BeginGetMyNumber("foo", "bar", "bat", 1, callback, state),
       instance.EndGetMyNumber, state: null);
    

    This technique (partial function application) works for begin methods with any number of input params.

提交回复
热议问题