Currently working on a multi-threaded WP 7.1.1 application and slightly more than half of the time the application quits during the "initial phase" without throwing any Exception. It simply ends with all threads returning 0x0 and without entering any Closing/Exit/Quit events.
...
The thread '<No Name>' (0xfde00d2) has exited with code 0 (0x0).
The thread '<No Name>' (0xe860116) has exited with code 0 (0x0).
The thread '<No Name>' (0xfdf00c6) has exited with code 0 (0x0).
The thread '<No Name>' (0xf8d012e) has exited with code 0 (0x0).
The thread '<No Name>' (0xfd5010e) has exited with code 0 (0x0).
The thread '<No Name>' (0xfbc011a) has exited with code 0 (0x0).
The thread '<No Name>' (0xf9900ee) has exited with code 0 (0x0).
The program '[268042506] UI Task: Managed' has exited with code 0 (0x0).
EOL
What does "initial phase" mean exactly? I profiled the app with "Windows Phone Performance Analysis" and together with some debug messages and some logging I estimate it is approximately 3-4 seconds after the start. At his point the GUI is already visible for a very brief amount of time.
I'm almost certain that the problem occurs duo to the following call:
private static List<MyEntries> EntriesLoad()
{
using(var context = Context.ReadOnly) // <- works
{
return context.MyEntries.Where(m => !m.Deleted).OrderBy(m => m.Name).ToList(); // <- problem
}
}
private async void EntriesReload()
{
EntriesLoaded = false; // <- called
var entries = await TaskEx.Run<List<MyEntries>>(EntriesLoad); // <- called
EntriesLoaded = true; // <- only get's called 50% of the time/ otherwise app quits
}
To prevent any multithreading issues with the DataContext, a new context is created on each call:
public static Context ReadOnly
{
get { return new Context(ConnectionReadOnly); }
}
I even tried BackgroundWorker and ThreadPool instead of the Async CTP 3, but with the same effect. I know very similiar questions have been been asked many times before, but I simply couldn't find any solution as of yet to my problem. Is there any way/ program I could find the exact method (reason, loc) that is causing the exception? Are there maybe any limits on how many threads can be created? Can DataContext be safely used in this manner?
Your help is much appreciated.