tonerdo / pose

Replace any .NET method (including static and non-virtual) with a delegate
MIT License
1.08k stars 74 forks source link

Isolating async calls #25

Open ghost opened 6 years ago

ghost commented 6 years ago

How on earth are you meant to isolate async calls? I've tried working round the issue with PoseContext.Isolate(async () => {}) and PoseContext.Isolate(() => Task.Run(async () => {})); but both throw compiler errors.

Any guidance/thoughts?

tonerdo commented 6 years ago

PoseContext doesn't support specifying async delegates directly. The best thing to do will be to create a separate async method and pass that to PoseContext. E.g.

public async void SomeMethodAsync()
{
    Task.Run(() => {});
}

PoseContext(() => SomeMethodAsync());
ghost commented 6 years ago

@tonerdo Looks like it doesn't support async full stop. Specifying an async method to pass to the Isolate method or returning a Task.Run that runs an async delegate from that method results in a compiler error. The only way I found to get this to work was to remove any asynchronous calls and hit the entry point synchronously. Not ideal, but it works I guess.

norgor commented 5 years ago

+1 👍

Yullissa commented 5 years ago

Is this bug fixed ???

ypedroo commented 3 years ago

Any update on this?

Miista commented 9 months ago

For support for async/await please see https://github.com/Miista/pose/issues/12

cc: @tonerdo @norgor @Yullissa @ypedroo @bramroelofs-tts