Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Creation of object in thread not accessible
Message
From
31/05/2011 11:01:10
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
 
To
All
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Creation of object in thread not accessible
Environment versions
Environment:
C# 4.0
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01512341
Message ID:
01512341
Views:
88
Hi all,

I have been moving some code to run in a background thread to speed up the performance. In my background worker I create the Configuration class which contains this property.
/// <summary>
/// Main Window State Setting
/// </summary>
public System.Windows.WindowState MainWindowState
{
	get { return OCSDApplication.Current.MainWindow.WindowState; }
	set { OCSDApplication.Current.MainWindow.WindowState = value; }
}
Later when Application.InitializeComponent is run, this fails because of "InvalidOperationException" - "The calling thread cannot access this object because a different thread owns it".

Is there a way when it is created to get the ownership of the class back on the main thread? This is WPF by the way.
Timothy
Timothy Bryan
Next
Reply
Map
View

Click here to load this message in the networking platform