473,791 Members | 2,711 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Event raised on different thread problem

Hi,

I have a dataset object that is binded to a datagrid in my main
thread. Now, when I add a row to the dataset object in a another
thread (since it may take awhile to complete), sometimes my
application will crash. I suspect this is because the ListChanged
event is raised on a different thread to the thread that my dataset
object was bound to the datagrid. My question is, how do I get around
this problem? I would think this would be a common problem, but
haven't found any answers.

Thanks in advance.
Jul 21 '05 #1
1 1286
"Kulgan" <ku*****@yahoo. com.au> wrote in message
news:3c******** *************** ***@posting.goo gle.com...
Hi,

I have a dataset object that is binded to a datagrid in my main
thread. Now, when I add a row to the dataset object in a another
thread (since it may take awhile to complete), sometimes my
application will crash. I suspect this is because the ListChanged
event is raised on a different thread to the thread that my dataset
object was bound to the datagrid. My question is, how do I get around
this problem? I would think this would be a common problem, but
haven't found any answers.


The answer is to add the row on the proper thread. Use dataGrid.Invoke .

John Saunders
Jul 21 '05 #2

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

Similar topics

6
3089
by: Iain | last post by:
I've got a (VC++ 6.0) com object which does something asynchronously (writes a DVD image, actually). It rasies COM events to indicate progress, including completion. I've got this running in a c# application, with the events coming up and being caught (The idea is to use this to Set a ManualResetEvent which will alow the rest of the processign to happen). However, when I put an event after the call to start the async process off,
1
4521
by: Andreas | last post by:
Hi, we have some problems with the following situation: A remote application A writes files to a directory monitored by a FileSystemWatcher-instance in application B. A creates the file with the initial ending "COPY_IN_PROGRESS" and only after successful copying the file gets renamed to its final ending "TO_DO". The FileSystemWatcher of B is set to react on the rename-event and upon recognizing an event some processing is triggered.
3
1741
by: Tom | last post by:
Dear experts, this time my problem is, that I will have objects of 3 different classes, which all should receive their events without knowing each other. In real life the following happens: I have three fingerprints which are waiting for a finger to be put on sensor.
20
2421
by: Bob Day | last post by:
Using VS 2003, VB, MSDE... There are two threads, A & B, that continously run and are started by Sub Main. They instantiationsl of identical code. Thread A handles call activity on telephone line 1 and Thread B handles call activity on telephone line 2. They use a common SQL datasource, but all DataSets are unique to each thread. Is there a way for thread A to occasionally communication to thread B that something has happened? ...
4
9815
by: Charles Law | last post by:
Suppose a worker thread needs to signal to the main thread that an event has occurred. Ordinarily, any event raised by the worker thread will be on its own thread. How can the worker thread raise an event on the main thread instead? TIA Charles
1
305
by: Kulgan | last post by:
Hi, I have a dataset object that is binded to a datagrid in my main thread. Now, when I add a row to the dataset object in a another thread (since it may take awhile to complete), sometimes my application will crash. I suspect this is because the ListChanged event is raised on a different thread to the thread that my dataset object was bound to the datagrid. My question is, how do I get around this problem? I would think this would be a...
9
14459
by: Marcelo Cabrera | last post by:
Hi, I have a user control that in turn creates a bunch of webcontrols dynamically and handles the events these webcontrols raise. It used to work fine on ASP .Net 1.1 but when compiled on 2.0 it does not. The problem is that the webcontrols get created on the OnLoad event of the usercontrol and the event handlers are assigned at the same time. I have to click twice on the controls for the events to be raised, the first time nothing...
19
4759
by: Daniela Roman | last post by:
Hello, I try to fire an event under a button click event and maybe anybody can give a clue please. I have let's say a WEB grid with PageIndexChanged event: private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
1
1675
by: Amit Dedhia | last post by:
Hi I am developing an application using C++/CLI in Visual Studio 2005. In my application I have following structure. (1) Class A creates instances of Class B and Class C. (2) Class B implements a timer function which repeatedly executes a timer every 250 ms. (3) Class C instance hooks for a event raised by Class B instance. Class B always raises this event asynchronously at the end of timer
0
9669
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9515
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10426
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10154
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9993
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5430
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5558
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.