473,399 Members | 3,656 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Exception in using control in Mainform

When I call a method by remoting I get the following exception-
"Control 'conrolname' accessed from a thread other than the thread it was
created on"
Can someone advise how to cope with that provided that I must use this call
somehow?
Regards
Gomez
Nov 17 '08 #1
3 1340
On Mon, 17 Nov 2008 13:28:55 -0800, Gomez <go***@john.comwrote:
When I call a method by remoting I get the following exception-
"Control 'conrolname' accessed from a thread other than the thread it
was created on"
Can someone advise how to cope with that provided that I must use this
call
somehow?
Yes. Search this newsgroup for the exact text of the exception
(excluding, of course, variable, type, and object names that are unique to
your own program). There is a wealth of information on that very subject.

Pete
Nov 17 '08 #2
"Gomez" <go***@john.comwrote in message
news:uB**************@TK2MSFTNGP02.phx.gbl...
When I call a method by remoting I get the following exception-
"Control 'conrolname' accessed from a thread other than the thread it was
created on"
Can someone advise how to cope with that provided that I must use this
call somehow?
You can transfer control from the remoting thread into the thread that
created the control by means of the method "Invoke" that all controls have.

For instance, if you are doing theControl.theProperty=theValue; in your
remoted method, you can replace it with this:

theControl.Invoke(new MethodInvoker(myMethod));
...
private void myMethod()
{
theControl.theProperty=theValue;
}

Of course, there are many ways to write the preceding, such as using an
anonymous method inside the call to Invoke instead of the separate myMethod.
This would let you 'capture' theValue instead of passing it around in a
member value as would be required by the previous code example.

Nov 17 '08 #3
On Nov 17, 4:28*pm, "Gomez" <go...@john.comwrote:
When I call a method by remoting I get the following exception-
"Control 'conrolname' accessed from a thread other than the thread it was
created on"
Can someone advise how to cope with that provided that I must use this call
somehow?
Regards
Gomez
You have to use Control.Invoke to make sure that y ou modify the
control from the UI thread. If you do a search for "Control.Invoke" in
this NG you will find a lot of posts about this
Nov 17 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: hazz | last post by:
My runtime in debug is dropping through the constructors from an upper level class into subclassed constructors..... namespace AB public class A : MarshalByRefObject public A () ...
0
by: Wilfried Mestdagh | last post by:
Hi, I use a class to hold certain runtime configuration settings. This class I serialize to a config file and load it again at program start. Sometimes (let's say 1 on 10) I have an invalid cast...
5
by: MJB | last post by:
I never get the above exception in Windows 2k. It only happens in Windows XP, which is the first oddity. My application is multi-threaded and I use the webbrowser control and media player. The...
4
by: ZorpiedoMan | last post by:
I just ran across an interesting phenon... If you bind a control, say a textbox, to a class.property, and in changing the value of the textbox an error is thrown in the class.property, you get...
4
by: Rob Richardson | last post by:
Greetings! I am working on an application that targets a Pocket PC running Windows CE and SQL Server CE. Almost all functions in the application use a Try block with a Catch block that looks...
4
by: sm | last post by:
Hi, I have a couple of questions with regards to handling errors and exceptions. 1. If I use On Error goto Errhandler ... Errhandler:
11
by: chopsnsauce | last post by:
Here's the example: Dim frm As New FORM1 Try frm.show Catch ex As Exception msgbox ex.message
0
by: Ben Crinion | last post by:
Hi Im getting the error below when i try and cosume this web service http://ftp.mediaburst.com/ben/wsdl/SearchService.wsdl. I think the error is due to the array in...
1
by: Ratz | last post by:
Hello everyone! I'm new to this Forum! I've spent about 56 hours trying to solve a .NET VB Runtime error while Using a program.Ive contacted the developer of the program and he could not figure out...
5
by: aine_canby | last post by:
Hi, The problem is that the line - this.Invoke(new MyDelegate(Function), args); // this = MainForm is being called after the line - terminatePopulate = true; therefore I get an exception...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.