I am not familiar with pubnub, but what you are trying to achieve should be as simple as this:
Pubnub pn = new Pubnub(publishKey, subscribeKey, secretKey, cipherKey, enableSSL); var tcs = new TaskCompletionSource<PubnubResult>(); pn.HereNow("testchannel", res =>
Please note that running an asynchronous file synchronously is not recommended. You should look at using async/await , in which case you would do:
var result = await tcs.Task;
source share