cross-threading

VB.NET - How to Hide a Form in Cross-Thread Operation

Hi u all, I need a function to Hide a form in cross -thread operation. I write this code but it close the form and not only hide it: Dim objHideMyForm As delegateUpdateApps = AddressOf HideFree Private Sub HideFree() Try Me.Hide() Catch End Try End Sub Public Sub HideMe() Me.Invoke(objHideMyForm) End Sub Can any...

working a textbox in a form from another class C#

so i have public class Form1 : Form {} and class Updater {} and i have textBox1 on Form1, along with many other controls... so here is my dilemma: i have a while(true) {} loop in Updater, and i couldn't stick it in the Form1 class, because it was preventing the form from loading. and i need to update a multi-lined textbox (textB...

Which cross threading invoke function is better for a control that is inherited?

I have a relatively simple question regarding the best way to call the DataGridView.Rows.Add function when it is inherited into the current control. Which is the best way to make the call to the inherited control? Call it directly in the invoke or call it using recursive-like function? They both seem to produce the same result, a row get...

Throwing exceptions in callback method for Timers

I was unable to find an answer to this question anywhere... What happens with the exceptions thrown in the callback method for System.Threading.Timer, (or in the event handler for System.Timers.Timer). Is the exception propagated to the thread on which the timer was created or is the exception lost? What are the side-effects of throwin...

SynchronizingObject for an event

With Timer objects, I can set the SynchronizingObject property to avoid having to use invoke when updating the GUI from the timer's event handler. If I have a class that instead subscribes to an event and has to update the GUI in the event handler, is there an analogous concept? Or do I have to write the InvokeRequired boilerplate code? ...

Getting "cross-thread operation not valid" even when using invoke method.

Hi... I get the "cross-thread operation not valid" here: if ( vlc.State == VlcPlayerControlState.PLAYING ) { if ( vlc.InvokeRequired ) { vlc.Invoke( new MediaPlayerNoParameterDelegate( vlc.Stop ) ); } else { vlc.Stop(); // debugger point...

How can I notify the main thread of some message on another thread without blocking and waiting?

I'm writing a c# component that will only be used internally at my company. The component encapsulates communication with a number of servers that particular desktop applications need to communicate with. The servers can send unsolicited messages to the component, which are 'caught' in a separate thread. I want the majority of this comp...

Add a control on a form, from another Thread.

Hello to everyone. This is my first post on this site, which I must say is, great! Well here is my problem, and I truly hope someone will be able to help me. I was trying to postpone adding controls to my main form, with a goal to speed up it's start time. Well I run in the following exception: Cross-thread operation not valid: ...

Cross-thread operation not valid

Hi All, I keep getting the following error when debugging. Cross-thread operation not valid: Control 'richTextBoxReceivedMsg' accessed from a thread other than the thread it was created on. Here's the code that it points to: public void OnDataReceived(IAsyncResult asyn) { try { SocketPacket socket...

Keeping a global reference to a control in WinForms for accessing GUI thread

(There's a tiny bit of history to this question, please bear with me) In this question, I talked about the possibility of centralising the 'cross thread' hocus-pocus that is required for updating the GUI like so: //Utility to avoid boiler-plate InvokeRequired code //Usage: SafeInvoker.Invoke(myCtrl, () => myCtrl.Enabled = false); publi...

How long is the delay between Control.Invoke() and the calling of its Delegate?

I have a code engine that plays long WAV files by playing smaller chunks in succession using the waveOutOpen and waveOutWrite API methods. In order to update my UI as the file plays, from the callback function as each buffer completes playing I Invoke a separate thread (because you want to do as little as possible inside the callback fu...

Cross-thread operation not valid when reading property

I am getting this error when I try to read a property from a custom panel control. The property returns the value of a textbox within the panel. How do I read the property that returns the value of the textbox control from another thread? Sample of my property code is below. I am not worried about the setter. Here is the eaxct error...

How to show Infragistics's UltraDesktopAlert from thread

hi. i am facing problem from many days. I have a thread listening for notificaitons from other system. whenever i receive a notification over socket i want to display it in Alert window using Infragistics's UltraDesktopAlert control. there is no winform in this class library. please tell me how to display it using a thread. a sample is...

Find owner thread of GUI control

Working on a .NET app, I've run in a 'cross-thread operation not valid' exception, only it seems to happen in the correct thread. Is there a way to find out which thread is the one where a specific control has been created? What I've found so far: The 'InvokeRequired' operation only tells IF the current thread is the "owner thread"......

Altering the ObservableCollection according to FileSystemWatcher change notification

Hi All, I'm trying to update my ObservableCollection as the FileSystemWatcher notifies changes. I know this is not possible because of cross thread operations. So i would like to get the name of the file created/deleted/renamed when the event is fired and update it in the UI thread once the event is completed, as we do in BackgroundWor...

C# Thread Pool Cross-Thread Communication

The Scenario I have a windows forms application containing a MAINFORM with a listbox on it. The MAINFORM also has a THREAD POOL that creates new threads and fires them off to do lots of different bits of processing. Whilst each of these different worker threads is doing its job, I want to report this progress back to my MAINFORM, howeve...

Cross Theaded Calls - Many controls Heavy GUI Application after .net 1.1 2.0 upgrade- best way ??

I have recently upgraded a .net1.1 solution to .net2.0. AS this is a very heavy GUI appilcation with loads of controls and many multithreaded operations that update the GUI. While these operations worked seamlessly in .net1.1 it is throwing up Cross Threaded Illegal operations after the upgrade. Considering the fact that tehre are numer...

Legacy application creates dialogs in non-ui thread.

I've been working support for a while on a legacy application and I've noticed a bit of a problem. The system is an incredibly complex client/server with standard and custom frameworks. One of the custom frameworks built into the application involves validating workflow actions. It finds potential errors, separates them into warnings a...

Call event from original thread ??

Hi all, Here is my problem, I have a class which have a object who throw an event and in this event I throw a custom event from my class. But unfortunately the original object throw the event from another thread and so my event is also throw on another thread. This cause a exception when my custom event try to access from controls. Her...

Delegates And Cross Thread Exception

Whenever i am updating UI in windows form using delegate it gives me cross thread exception why it is happening like this? is there new thread started for each delegate call ? void Port_DataReceived(object sender, SerialDataReceivedEventArgs e) { //this call delegate to display data clsConnect(statusMsg); } protected ...