473,769 Members | 7,097 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Client callback adding items to databound collection = crossthread error

I understand the concepts and rules for invoking UI methods from a non-UI
thread. In the past I have always checked with the control's InvokeRequired
property and Invoked my delegate accordingly. This has worked fine, nothing
special.

BUT, I am now working on my first client/server app and I have a slightly
new challenge that I'm not finding a good solution for.

My client passes an EventShim with a callback to the server. When something
special happens on the server it fires this event which the client of course
responds to.

The event handler on the client is taking args from the server-fired event
and adding items to a DataBound collection. I designed it this way on
purpose, I didn't want to tear down and build up the UI controls every time
a couple new items came over, data binding seemed a perfect fit.

Problem is that when the items are added to the collection and they raise
the INotifyChange event (I think that's the one) I'm getting cross-thread
exceptions. Not surprising. Now, since I'm not directly making calls to a
"UI" object my old habits of InvokeRequire/BeginInvoke on the control won't
work.

My question: How do I invoke a delegate on the UI thread without having
acccess to a System.Windows. Forms.Control object? How else can we execute
on the UI thread?

Thanks for any help, I'm close to getting this deliverable wrapped up and
going to sleep (just in time for breakfast!) :0)

-Steve
Jan 10 '08 #1
0 1422

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

Similar topics

3
2630
by: Joe Molloy | last post by:
Hey again, Anybody have any ideas about how I would go about adding attributes to the listitems in a databound dropdownlist? Asp.net debugger has kindly informed me that dropdown list is not a collection so that 'for each listitem in dropdownlist' style code won't work. Joe
2
3049
by: Shiju Poyilil | last post by:
Hi ! I have a requirement wherein i am binding a datalist which contains a label (Caption for the field) and some literal hidden fields and a dropdown list. When I am binding to the datalist.. only the labels (caption) and the invisible literal controls are binded.. Now based on the invisible literal control values I get the information from DB to bind it with each dropdown list (I am doing this in the item databound event) Also based on...
4
2309
by: Harold | last post by:
I have read the following article http://www.4guysfromrolla.com/webtech/073101-1.shtml. I added the empty selection as the first option. When I click submit without choosing anything it does not return my empty string but the 2nd value in listbox. When the page reloads it selects the 2nd option by default even thou my Empty field is in the list. What do I have to do to get the empty field and databound data to act as one?
0
1153
by: FishingScout | last post by:
I am re-writing an MS VC++ 6.0 application in Visual Studio 2005 VB.NET. In order for my new application to communicate with some hardware (an RFID reader) I need to communicate with a DLL that was written in MS VC++ 6.0. I have found some excellent discussions that have helped me define the structures to marshal the data between the unmanaged and managed code. My problem is that my application is not working correctly. The result is...
4
1989
by: FishingScout | last post by:
I am re-writing an MS VC++ 6.0 application in Visual Studio 2005 VB.NET. In order for my new application to communicate with some hardware (an RFID reader) I need to communicate with a DLL that was written in MS VC++ 6.0. I have found some excellent discussions that have helped me define the structures to marshal the data between the unmanaged and managed code. My problem is that my application is not working correctly. The result is...
1
17047
by: Timbo | last post by:
Hi all, This is my first message here so i'll try and include all the information that will help you help me out, if possible. Basically I am using C# in ASP.NET 2.0 and have a Repeater control in my aspx page with two image buttons, one for an edit command, another a delete command. Here is a cut down code fragment. ...
0
1964
by: mollyf | last post by:
I've got a combo box that I want to bind a collection to. I got the error "Complex Data Binding accepts as a data source either an IList or an IListSource" so I tried using the BindingSource, which works except when I want to have a blank line as the first item in the combo box--then all that is displayed is the type of object. Here is the code for filling the collection: Public Function GetCollection(ByRef cndb As SqlConnection,...
2
2430
by: FatherUCKing | last post by:
I'm trying to implement an add / remove listbox system ...one listbox has available values the second represents the saved values. Using the client-callback features, how would I write the code to ensure that the control state of the saved selections listbox represents the changes that occurred on the clientside (ie adding / removing items) and keep it synchronized with the server representation of the listbox?
0
1900
by: marcobx | last post by:
I have a ComboBox and a List of objects to popolate items. I use the DataSource property and not the List collection: List<foolst = new List<foo>; //add elements into the list //... comboBox1.DataSource = lst; This work fine, items appear. Now I have a button near the combo box and I want to add a new element
0
9589
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
10214
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...
0
10048
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9996
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
8872
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6674
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();...
1
3963
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3563
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.