Skip to main content
grammar
Source Link
Alwyn
  • 8.3k
  • 12
  • 66
  • 115

This does not throw compile error, but why?

public async void DoSomething(object arg){ ... } Action<object> myAnonActionDelegate = DoSomething; 

Shouldn't "DoSomething" have a signature of type Func<object,Task> as opposed to Action? In fact it "DoSomething" wouldis not be assignable to Func<object,Task> delegate.

The question is why? Is my understanding about async keyword off?

This does not throw compile error, but why?

public async void DoSomething(object arg){ ... } Action<object> myAnonActionDelegate = DoSomething; 

Shouldn't "DoSomething" have a signature of type Func<object,Task> as opposed to Action? In fact it "DoSomething" would not be assignable to Func<object,Task> delegate.

The question is why? Is my understanding about async keyword off?

This does not throw compile error, but why?

public async void DoSomething(object arg){ ... } Action<object> myAnonActionDelegate = DoSomething; 

Shouldn't "DoSomething" have a signature of type Func<object,Task> as opposed to Action? In fact "DoSomething" is not be assignable to Func<object,Task> delegate.

The question is why? Is my understanding about async keyword off?

Source Link
Alwyn
  • 8.3k
  • 12
  • 66
  • 115

C# .net 4.5 async delegate

This does not throw compile error, but why?

public async void DoSomething(object arg){ ... } Action<object> myAnonActionDelegate = DoSomething; 

Shouldn't "DoSomething" have a signature of type Func<object,Task> as opposed to Action? In fact it "DoSomething" would not be assignable to Func<object,Task> delegate.

The question is why? Is my understanding about async keyword off?