I have a 3rd party DLL that I cannot change and I wanted to make asynchronous one of its method.
So I have:
procedure bool Food()
{
Task<ReturnClass> response = SomeDLL.SyncMethod(); // Method returns "ReturnClass"
response.ContinueWith (_ =>
{
return response.Result != null;
});
}
I get the known compile error:
Cannot implicitly convert type 'SomeDLL.ReturnClass' to 'System.Threading.Tasks.Task'
It's important to notice that I cannot change the 3rd PartyDLL
What's the right way to accomplish this goal?
I need to wait for the SomeDLL SyncMethod return so that's why I used ContinueWith.Does the procedure bool Foo need to set as "async"?
bool, not aTask<bool>, andSomeDLL.Method()clearly returns aTask, based on the first line of the method. This is very much a sync over async wrapper.SomeDLL.Method()is sync (I wanted to make asynchronous one of its method) and the first line of the method generates a compile-time error the OP is trying to fix.