Connecting Tech Pros Worldwide Forums | Help | Site Map

How to set Form.Owner property across two threads with message pumps?

Polanski24
Guest
 
Posts: n/a
#1: Apr 6 '06
Hello!

It was simple in .NET 1.1

public void SetOwner(Form owner)
{
if (this.InvokeRequired)
{
this.Invoke(
new OwnerSetDelegate(this.SetOwner), new object[] { owner });
}
else
{
this.Owner = owner; // InvalidOperationException in .NET 2.0
}
}

public delegate void OwnerSetDelegate(Form value);

While in .NET 2.0 InvalidOperationException is thrown because code
tries to access owner accross threads - how can I beat this dead
circle?

Cheers

http://sourceforge.net/projects/ngmp


Closed Thread