I'm writing a WinForms app which has two modes: console or GUI. Three projects within the same solution, one for the console app, one for the UI forms and the third to hold the logic that the two interfaces will both connect too. The Console app runs absolutely smoothly.
A model which holds the user-selections, it has an IList<T> wher...
I have a server application that receives information over a network and processes it.
The server is multi-threaded and handles multiple sockets at time, and threads are created without my control through BeginInvoke and EndInvoke style methods, which are chained by corresponding callback functions.
I'm trying to create a form, in addit...
This is baffling me, maybe somebody can shine the light of education on my ignorance. This is in a C# windows app. I am accessing the contents of a listbox from a thread. When I try to access it like thisprgAll.Maximum = lbFolders.SelectedItems.Count;
I get the error. However, here is the part I don't get. If I comment out that line...
I am having some problems with events being raised from the non-UI thread, in that i dont wish to have to handle the If me.invokerequired on every event handler added to the thread in Form1.
I am sure i have read somewhere how to use a delegate event (on SO) but i am unable to find it.
Public Class Form1
Private WithEvents _to As ...
Are there any issues with changing elements which will appear on a web page within a thread. I am from a windows programming background and obviously if a thread needs to change the GUI in some way you have to delegate it to the GUI thread.
Basically my page uses 3 sql queries which can be run concurrently to obtain the page data. So I ...
I have a lengthy user-interface operation on my form which is triggered whenever an event is fired. Rather than have the UI block while the operation takes place, I'd like to perform the operation in another thread, and abort that thread and start again if the event fires again.
However, to safely alter controls on my form, I need to u...
This code is executed by many way. When it's executed by the form button it works (the button start a thread and in the loop it call this method = it works). BUT it doesn't work when I have a call to that method from my BackgroundWorker in the form.
With the following code:
private void resizeThreadSafe(int width, int height)
{
if...
Hi,
I realise that I can't access Form controls from the DoWork event handler of a BackgroundWorker. (And if I try to, I get an Exception, as expected).
However, am I allowed to access other (custom) objects that exist on my Form?
For instance, I've created a "Settings" class and instantiated it in my Form and I seem to be able to re...
To able to do proper cross-thread access I'm using a piece of code something like this :
Private Delegate Sub DelSetButton(ByVal button As Button, ByVal label As String, ByVal enabled As Boolean)
Private Sub SetButton(ByVal button As Button, ByVal label As String, ByVal enabled As Boolean)
If InvokeRequired Then
Invoke(New ...
In a c# program for simulating a lan messenger, i have a callback function for beginreceive where i need to display the text received in a particular textbox..
this.textBox1.Text = sb.ToString();
However on doing so, I am getting a cross-thread operation not valid error.
I do realize that i need to use the object.invoke method but could...
In a program in c# I have 2 threads apart from the main thread.
When the user closes the form I want to terminate one of the threads from the main thread.
How do I go about doing so?. Please provide me with the code if possible.
...
Hello,
I have a PyQt program, in this program I start a new thread for drawing a complicated image.
I want to know when the thread has finished so I can print the image on the form.
The only obstacle I'm facing is that I need to invoke the method of drawing from inside the GUI thread, so I want a way to tell the GUI thread to do someth...
I have a simple UserControl for database paging, that uses a controller to perform the actual DAL calls. I use a BackgroundWorker to perform the heavy lifting, and on the OnWorkCompleted event I re-enable some buttons, change a TextBox.Text property and raise an event for the parent form.
Form A holds my UserControl. When I click on som...
I've been struggling with this for quite a while:
I have a function designed to add control to a panel with cross-thread handling, the problem is that though the panel and the control are in "InvokeRequired=false" - I get an exception telling me that one of the controls inner controls are accessed from a thread other than the thread it w...
Dear all,
I come to you to see if someone has an idea on how to solve a problem I've come across while doing a migration to ActiveMQ.
I'm using ActiveMQ to send notifications within this project (in C#), and after finishing the implementation i found some errors concerning threading problems. (
I know that the solution for that exception...
Hey fellas.
I have an application that is designed to be run across a network. This means that the initial run of this application can take a while. So I've been putting together a splash screen to pretty the process up some.
It uses threading to show the form via a static method. I'm still something of a threading novice, so when I go...
For some reason, this safe-looking method raises a classic exception.
Cross-thread operation not valid:
Control 'statusLabel' accessed from a
thread other than the thread it was
created on.
This code obviously should call an anonymous method through Invoke when invoke is required.
But the exception occurs every once in a whil...
Hello,
I am trying to listen to COM port so that I create new handler for SerialPort.DataReceived event. The logic is simple - I write something to TextBox1, press Button1 and my text should show it self in Label1. But my application don't want to run, becouse it throws 'Cross thread operation not valid' error.
I did some searching and...
Is this an appropriate way of handling cross-thread operations?
Should I use a new property name, something like "EditValueThreadSafe" instead of overriding "EditValue"? I don't think there is an issue with the changes to the implementation of EditValue, as the base property is called regardless.
namespace MyApplication.Components
{
...
Hey Guys,
I've got a cross thread invoke going on, and the invoke works fine, however I have found that all subsequent function calls need to be invoked aswell, otherwise it throws exceptions, how do I go about either modifiying my invoke command, or through some other solution, fix this?
This is my current invoker:
foreach (chat_wind...