On 16.08.2012 21:52, Stephan Steiner wrote: > Hi > > I'm having a weird issue using the TPF. > In my main activity, in the OnCreate method I'm trying to initialize network > connectivity (which potentially could take a while - I need to check if one > of two addresses is reachable). > > > So, within OnCreate, I start a new task (for simplicity's sake I do nothing > with the return value for now) > > Task.Factory.StartNew(() => > { > bool initialized = Controller.Instance.Initialize(); > }); > > Controller.Instance is a singleton which gets initialized upon startup, > using the standard singleton approach > > public static Controller Instance > { > get > { > if (myController == null) > { > Log.Info(MainActivity.AppId, "Controller not yet > instantiated"); > lock (syncRoot) > { > if (myController == null) > { > Log.Info(MainActivity.AppId, "Instantiating > controller"); > myController = new Controller(); > } > } > } > return myController; > } > } > > Now, if I run this code, it gets as far as the second Log.Info string, then > ... nothing. No errors, no exceptions, no nothing whatsoever. If I step > through the code and press F11 on the "myController = new Controller()" > line, it jumps to the end of the file. > > If I run the same code within the GUI thread > > bool initialized = Controller.Instance.Initialize(); > > Then, things work as they should. > > How can I figure out a) what is going on here, You could run the program with debugger attached and when you think your task is hanging you simply pause the debugger and check the threads window for your background thread, select it and have a look in the callstack window where the task is currently in code. if you are lucky, the task is in your code or in mono4android code and you get a good stacktrace. if it really is hanging (i.e. a deadlock or a blocking method call) it will always be the same line of code. hth, -- henon > b) how to counteract it? > > Thanks > Stephan > > > > -- > View this message in context: > http://mono-for-android.1047100.n5.nabble.com/Task-Parallel-Framework-issues-tp5711359.html > Sent from the Mono for Android mailing list archive at Nabble.com. > _______________________________________________ > Monodroid mailing list > Monodroid@lists.ximian.com > > UNSUBSCRIBE INFORMATION: > http://lists.ximian.com/mailman/listinfo/monodroid > _______________________________________________ Monodroid mailing list Monodroid@lists.ximian.com
UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid