Hello,
I've been trying to debug this asynchronous call I'm working with with an external service, Pubnub (https://www.pubnub.com/docs/c-sharp-dotnet-c-sharp/api-reference#here_now_example_4) and I'm trying to tackle it from two angles. I seem to be running into a question that might be Xamarin-related, so I am going to post it here.
I'm running the code as mentioned in the link in my question, and in my Xamarin debug window, I am seeing
Thread started: <Thread Pool> #9 Thread started: <Thread Pool> #10 Thread started: <Thread Pool> #11 Thread finished: <Thread Pool> #10 Thread finished: <Thread Pool> #11 Thread finished: <Thread Pool> #9
My code never seems to execute, and I don't know if I need to handle asynchronous functions differently in Xamarin, or if it's even possible. The application seems to hang when I stick the code in a TouchUpInside
event in my ViewController
button.TouchUpInside += delegate { pubnub.HereNow() .IncludeState(true) // include state with request (false by default) .IncludeUUIDs(true) // if false, only shows occupancy count .Async(new DemoHereNowResult()); } //.... public class DemoHereNowResult : PNCallback<PNHereNowResult> { public override void OnResponse(PNHereNowResult result, PNStatus status) { Console.WriteLine("a"); } };
Does anyone have ideas?
I do not have event listeners for the response, however.. Wrapping up the code inside of Task.Run()
solves the issue.
Code sample is in here: https://forums.xamarin.com/discussion/comment/263893#Comment_263893
Answers
Do you have listeners for the event response? It looks like the listeners are explained further up the api reference you're working from.
I do not have event listeners for the response, however.. Wrapping up the code inside of
Task.Run()
solves the issue.Code sample is in here: https://forums.xamarin.com/discussion/comment/263893#Comment_263893