am using a synchronous 3rd function which I cannot modify, such as:
public void startDoSth(Action<string> onDone)
startDoSth
spawn a new thread to do the job, and returns immediately, and when the thing is done, my onDone
function would be called.
I'd like to write an asynchronous method like below to wrap it:
public async Task<string> doSthAsync();
So, someone can call it like this:
string s = await doSthAsync()
onDone(s)
In doSthasync()
I call startDoSth()
to do the real thing.
But I have no idea how to write the doSthAsync()
.
Could anyone tell if it is possible and how to do it? Thanks a lot.