I ran into a strange problem with a compact framework application last week and narrowed it done to the following code.
The program.cs code creates an instance of the singelton form and then calls Application.Run(). The form creates a worker thread that is implemented as part of a static class. The worker thread gets stuck in the foreach loop in WorkerThreadFunc() which blocks the main thread from finishing its initialization. I can avoid the problem by using a for loop in the thread, not using a singelton for the form, or initializing the thread from form.load() rather than the constructor. Can someone please explain to me why this lockup occurs?
Philip
Program.cs
using
namespace
{
[
}
ForEachLockup.cs:
InitializeComponent();
lstDummy =
lstDummy.Add(i);
WorkerThread =
WorkerThread.Name =
WorkerThread.Priority =
WorkerThread.IsBackground =
WorkerThread.Start();
iDoSomething++;