Multi Threaded Form

G

Guest

HI,

Any help would be appreciated but I'm guessing this is wrong or seomthing.
I'm creating a wait form on a sepearate thread so that I can perform updates
to my main form on the original thread. It doesn't do anything fancy and
there are no buttons or events for mouse or keyboard or anything it's just
there.

When I create the new form on the wait form thread it blocks on the
constructor. I've done a bit of digging and found the
WIndowsFormSynchronizationContext class which is called by the control
constructor. When I set that classes AutoInstall property to false then the
constructor of the wait form completes correctly and everything seems to run
fine.

I was wondering if anyone knew anything about this class and the
implications of turning it to autoinstall to false. I switch it back on after
the constructor but I don't want to take my chances.

Other than that it works perfectly.
 
G

Guest

OK, big screw up. That switch turned out to be a mistake, but I'm not sure
why when in one instance actually it works sucessfyll, yet in others this
class seems to block the code.

Can anyone help?
 
S

Stoitcho Goutsev \(100\) [C# MVP]

Hi,

Can you post working, compilable sample code that demonstrates the problem?
 
G

Guest

OK completly ignore this post entirly, with the correct placement of an
Application.DoEvents, and the moving of my ManualResetEvent.WaitOne I got it
working without any silly hacks.

Wow. I made a whole post all to myself.
 
G

Guest

It's OK, I got it working.

Cheers anyway.

Stoitcho Goutsev (100) said:
Hi,

Can you post working, compilable sample code that demonstrates the problem?


--

Stoitcho Goutsev (100) [C# MVP]

uAsking said:
HI,

Any help would be appreciated but I'm guessing this is wrong or seomthing.
I'm creating a wait form on a sepearate thread so that I can perform
updates
to my main form on the original thread. It doesn't do anything fancy and
there are no buttons or events for mouse or keyboard or anything it's just
there.

When I create the new form on the wait form thread it blocks on the
constructor. I've done a bit of digging and found the
WIndowsFormSynchronizationContext class which is called by the control
constructor. When I set that classes AutoInstall property to false then
the
constructor of the wait form completes correctly and everything seems to
run
fine.

I was wondering if anyone knew anything about this class and the
implications of turning it to autoinstall to false. I switch it back on
after
the constructor but I don't want to take my chances.

Other than that it works perfectly.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top