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, 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

Reply via email to