473,761 Members | 5,848 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

thread hangs .. why ? + example project

Hi,

I am having a thread hang problem in my c# code.

The example on the website: http://csharp.web1000.com/ is a
simplified version of my problem.

You will see in the form that a method TestThread increments a number in the
textbox on the form.
TestThread is called from a worker thread (2nd thread) using a TimerThread.
Every 2 seconds it will increment the number in te text box.

First start the project from the form (form1 class is the startup object).
The Form is displayed. Now push the button, this will create the
TimerThread.
You now see nicely that the number increments every 2 seconds.

Now start the application from the class (class1 is the startup object).
Now the TimerThread will be created in the Class1 object.
You will see that the number is never incremented.

When stepping through the code you will see that the TestThread method is
called.
The TestThread code in the form properly detects that this is run from a
second thread (line InvokeRequired) and continues to the line where Invoke
is called. I use Invole so that the increment function would run on the
forms thread. It is here where the application seems to hang. The number in
the textbox is never incremented.

Can anyone explain me why this is happening or how to solve this ?
i was wondering, might this have something to do with Apparementthrea ding ?
(this is used when you start the application from the form (=startup
object)).
Maybe when you start it from the class this is no longer the case ?
Maybe it's something completely different.
Thanks for shedding some light in the darkness.

Regards, Serge

http://csharp.web1000.com/
Nov 15 '05 #1
5 4029
Thanks 100
That helps me a lot. I already read about this message loop a couple of time
but now it's slowly all coming together.

Now just for the test I followed your suggestion and added the
Application.Run to my code so that the message loop would be started.
Specifically i added in my static Main method (from the class that is
defined as start object) the Application.Run line.
The problem I have here is that the code from Main method after the
Application.Run line is only executed when the form is closed again. And
that is not what I want.

I can not simply add this code in the form.
The reason for this is that this form is a simple status window.
It is shared by all my applications and contains no intelligent code. It
just displays the progress of the application.
The real work is done in the classes that are set as the start-up object.

So now I need a way to figure out how to start my application from my class
and still start this form's message loop using the application.run line.
Do you know a way ?
I can think of some solution using delegates but don't know if this is the
best practise.

Thanks in advance for your suggestions,

Regards,

Serge
"100" <10*@100.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Hi Serge,

Application will hang for sure. When you use the Main method in Class1 as a start point. There is no code starting the message loop (Application.Ru n).
At least Control.Invoke uses messages to switch the execution over the UI
thread. Further more if there is no message loop you cannot move, resize,
close or do anything with the form. Form is freezed on the screen. It won't even repaint itself.

What you might want to do is.
1. Remove
_frmStatus.Show ();
_frmStatus.Refr esh();
from the code. You don't need them.
2. Insted of
while(true)
{
Thread.Sleep(10 00);
}

put the following:
System.Windows. Forms.Applicati on.Run(_frmStat us);

That makes the code almost like the one you have in the form's class.

HTH
B\rgds
100

"Serge" <se**********@h otmail.com> wrote in message
news:3f******** *************** @reader3.news.s kynet.be...
Hi,

I am having a thread hang problem in my c# code.

The example on the website: http://csharp.web1000.com/ is a
simplified version of my problem.

You will see in the form that a method TestThread increments a number in the
textbox on the form.
TestThread is called from a worker thread (2nd thread) using a

TimerThread.
Every 2 seconds it will increment the number in te text box.

First start the project from the form (form1 class is the startup object). The Form is displayed. Now push the button, this will create the
TimerThread.
You now see nicely that the number increments every 2 seconds.

Now start the application from the class (class1 is the startup object).
Now the TimerThread will be created in the Class1 object.
You will see that the number is never incremented.

When stepping through the code you will see that the TestThread method is called.
The TestThread code in the form properly detects that this is run from a
second thread (line InvokeRequired) and continues to the line where Invoke is called. I use Invole so that the increment function would run on the
forms thread. It is here where the application seems to hang. The number

in
the textbox is never incremented.

Can anyone explain me why this is happening or how to solve this ?
i was wondering, might this have something to do with

Apparementthrea ding ?
(this is used when you start the application from the form (=startup
object)).
Maybe when you start it from the class this is no longer the case ?
Maybe it's something completely different.
Thanks for shedding some light in the darkness.

Regards, Serge

http://csharp.web1000.com/


Nov 15 '05 #2
forgot to explain in more detailed my reaction to your possible solution:

you said that it's better to have application.run instead of the

while(true)
{
Thread.Sleep(10 00);
}

This is possible but in that case i create the status form after I start the
worker thread.
thereby I get into a problem becuase my worker thread might raise a status
event to be displayed on the status form before that the status form is
actually created.

i would prefer to create the status form first and then launch my worker
thread.

Thanks in advance for your suggestions,

Regards,
Serge
"100" <10*@100.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Hi Serge,

Application will hang for sure. When you use the Main method in Class1 as a start point. There is no code starting the message loop (Application.Ru n).
At least Control.Invoke uses messages to switch the execution over the UI
thread. Further more if there is no message loop you cannot move, resize,
close or do anything with the form. Form is freezed on the screen. It won't even repaint itself.

What you might want to do is.
1. Remove
_frmStatus.Show ();
_frmStatus.Refr esh();
from the code. You don't need them.
2. Insted of
while(true)
{
Thread.Sleep(10 00);
}

put the following:
System.Windows. Forms.Applicati on.Run(_frmStat us);

That makes the code almost like the one you have in the form's class.

HTH
B\rgds
100

"Serge" <se**********@h otmail.com> wrote in message
news:3f******** *************** @reader3.news.s kynet.be...
Hi,

I am having a thread hang problem in my c# code.

The example on the website: http://csharp.web1000.com/ is a
simplified version of my problem.

You will see in the form that a method TestThread increments a number in the
textbox on the form.
TestThread is called from a worker thread (2nd thread) using a

TimerThread.
Every 2 seconds it will increment the number in te text box.

First start the project from the form (form1 class is the startup object). The Form is displayed. Now push the button, this will create the
TimerThread.
You now see nicely that the number increments every 2 seconds.

Now start the application from the class (class1 is the startup object).
Now the TimerThread will be created in the Class1 object.
You will see that the number is never incremented.

When stepping through the code you will see that the TestThread method is called.
The TestThread code in the form properly detects that this is run from a
second thread (line InvokeRequired) and continues to the line where Invoke is called. I use Invole so that the increment function would run on the
forms thread. It is here where the application seems to hang. The number

in
the textbox is never incremented.

Can anyone explain me why this is happening or how to solve this ?
i was wondering, might this have something to do with

Apparementthrea ding ?
(this is used when you start the application from the form (=startup
object)).
Maybe when you start it from the class this is no longer the case ?
Maybe it's something completely different.
Thanks for shedding some light in the darkness.

Regards, Serge

http://csharp.web1000.com/


Nov 15 '05 #3
100
Hi Serge,
Yes, you are right. The code after Application Run will be executed only
after the main window (passed to Run method) as a parameter is closed. In
this case when the application is closed. You cannot have alive windwos in
Windwos without messeage loop to dispatch messages to it. What I want to say
is all GUI applications has to have at least one UI thread (for windows
forms this is thread that eventually calls Application.Run ) All UI
commponents has to be created by an UI thread.
What you might want to do in your case is to have 2 threads: one worker
thread and one UI thread to dispalay the status. See my code below.
The changes are:
1. I removed the Main method from Form1 class. We don't need it anymore.
2. I Added two new methods in Form1 class: Run and CloseForm(It could be
just Close, but I had to hide the base one).
3. Modified Class1's Main method.
4. I use the old timer to update the status form, but you can use whatever
fits better with your needs. The only things is that the changes you make to
any UI components has to be made by the UI thread owning the component.
Which means that all threads but the UI thread itself has to use
Control.Invoke method.
//-------------------- Form1.cs -------------------------------//
using System;
using System.Drawing;
using System.Collecti ons;
using System.Componen tModel;
using System.Windows. Forms;
using System.Data;
using System.Threadin g;

namespace _ThreadTest
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows. Forms.Form
{
public System.Windows. Forms.Button button1;
private System.Windows. Forms.TextBox txtForm;
private System.Windows. Forms.Label label1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.Componen tModel.Containe r components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeCompo nent();

//
// TODO: Add any constructor code after InitializeCompo nent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Disp ose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.txtForm = new System.Windows. Forms.TextBox() ;
this.button1 = new System.Windows. Forms.Button();
this.label1 = new System.Windows. Forms.Label();
this.SuspendLay out();
//
// txtForm
//
this.txtForm.En abled = false;
this.txtForm.Lo cation = new System.Drawing. Point(8, 8);
this.txtForm.Na me = "txtForm";
this.txtForm.Si ze = new System.Drawing. Size(48, 20);
this.txtForm.Ta bIndex = 0;
this.txtForm.Te xt = "0";
this.txtForm.Te xtAlign = System.Windows. Forms.Horizonta lAlignment.Cent er;
//
// button1
//
this.button1.Lo cation = new System.Drawing. Point(128, 8);
this.button1.Na me = "button1";
this.button1.Si ze = new System.Drawing. Size(192, 24);
this.button1.Ta bIndex = 1;
this.button1.Te xt = "Start Thread In Form Code - OK";
this.button1.Cl ick += new System.EventHan dler(this.butto n1_Click);
//
// label1
//
this.label1.Fon t = new System.Drawing. Font("Microsoft Sans Serif",
7.764706F, System.Drawing. FontStyle.Bold, System.Drawing. GraphicsUnit.Po int,
((System.Byte)( 0)));
this.label1.Loc ation = new System.Drawing. Point(128, 8);
this.label1.Nam e = "label1";
this.label1.Siz e = new System.Drawing. Size(184, 24);
this.label1.Tab Index = 2;
this.label1.Tex t = "Thread started from code = BAD";
//
// Form1
//
this.AutoScaleB aseSize = new System.Drawing. Size(5, 13);
this.ClientSize = new System.Drawing. Size(336, 36);
this.Controls.A dd(this.button1 );
this.Controls.A dd(this.txtForm );
this.Controls.A dd(this.label1) ;
this.Name = "Form1";
this.Text = "Increment every 2 ses - thread test";
this.ResumeLayo ut(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
public void Run()
{
Thread uiThread = new Thread(new ThreadStart(Sta tusThreadProc)) ;
uiThread.Apartm entState = ApartmentState. STA;
uiThread.Start( );
}
public void CloseForm()
{
if(InvokeRequir ed)
{
this.Invoke(new MethodInvoker(C loseForm));
}
this.Close();
}
/// <summary>Star ts message loop (this thread is UI thread.)</summary>
public void StatusThreadPro c()
{
Application.Run (this);
}

private void button1_Click(o bject sender, System.EventArg s e)
{
// Create the delegate that invokes methods for the timer.
TimerCallback timerDelegate = new TimerCallback(T estThread);

// Create a timer that waits one second, then invokes every second.
System.Threadin g.Timer timer = new System.Threadin g.Timer( timerDelegate,
"nothing" ,1000, 2000);

}

public void TestThread(obje ct state)
{
if (! this.InvokeRequ ired )
{
base.Refresh();
txtForm.Text = (int.Parse(txtF orm.Text) + 1).ToString();
}
else
{
Invoke(new WaitCallback(Te stThread), new object[] {state});
}
}
}
}
//-------------------------------
Class1.cs ----------------------------------------
using System;
using System.Threadin g;
namespace _ThreadTest
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public class Class1
{
private static Form1 _frmStatus;
private static TimerCallback timerDelegate;
private static System.Threadin g.Timer timer;
public Class1()
{
}

[STAThread]
static void Main(string[] args)
{

_frmStatus = new Form1();
_frmStatus.butt on1.Visible = false;
_frmStatus.Run( );

// Create the delegate that invokes methods for the timer.
timerDelegate = new TimerCallback(_ frmStatus.TestT hread);

// Create a timer that waits one second, then invokes every second.
timer = new System.Threadin g.Timer( timerDelegate, "nothing" ,1000,
10000);
for(int i = 0; i < 20; i++)
{
//Do some job
Thread.Sleep(10 00);
}
//Stop the close the status form. (This will exit the UI thread).
_frmStatus.Clos eForm();

//You can do more work here

}
}
}
HTH
B\rgds
100
Nov 15 '05 #4
Possible the simplest way would be to create another form - MainForm -
which you will start with Application.Run
Form could be invisible - just hide it on load for example. Show your status
window from MainForm.Load.
Move your code (which is after Application.Run ) into MainForm.Load.

Another way is to use threads as was suggested by other posters.

There are more advanced techniques of course, like creating message-only
window, which involves Win32 API (check HWND_MESSAGE - SetParent or
CreateWindowEx) . Btw, this one could be used to transform your MainForm into
message-only window. It has some limitations, but could work for you too.

HTH
Alex

"Serge" <se**********@h otmail.com> wrote in message
news:3f******** **************@ reader0.news.sk ynet.be...
Thanks 100
That helps me a lot. I already read about this message loop a couple of time but now it's slowly all coming together.

Now just for the test I followed your suggestion and added the
Application.Run to my code so that the message loop would be started.
Specifically i added in my static Main method (from the class that is
defined as start object) the Application.Run line.
The problem I have here is that the code from Main method after the
Application.Run line is only executed when the form is closed again. And
that is not what I want.

I can not simply add this code in the form.
The reason for this is that this form is a simple status window.
It is shared by all my applications and contains no intelligent code. It
just displays the progress of the application.
The real work is done in the classes that are set as the start-up object.

So now I need a way to figure out how to start my application from my class and still start this form's message loop using the application.run line.
Do you know a way ?
I can think of some solution using delegates but don't know if this is the
best practise.

Thanks in advance for your suggestions,

Regards,

Serge
"100" <10*@100.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Hi Serge,

Application will hang for sure. When you use the Main method in Class1 as
a
start point. There is no code starting the message loop (Application.Ru n). At least Control.Invoke uses messages to switch the execution over the UI thread. Further more if there is no message loop you cannot move, resize, close or do anything with the form. Form is freezed on the screen. It

won't
even repaint itself.

What you might want to do is.
1. Remove
_frmStatus.Show ();
_frmStatus.Refr esh();
from the code. You don't need them.
2. Insted of
while(true)
{
Thread.Sleep(10 00);
}

put the following:
System.Windows. Forms.Applicati on.Run(_frmStat us);

That makes the code almost like the one you have in the form's class.

HTH
B\rgds
100

"Serge" <se**********@h otmail.com> wrote in message
news:3f******** *************** @reader3.news.s kynet.be...
Hi,

I am having a thread hang problem in my c# code.

The example on the website: http://csharp.web1000.com/ is a
simplified version of my problem.

You will see in the form that a method TestThread increments a number in
the
textbox on the form.
TestThread is called from a worker thread (2nd thread) using a

TimerThread.
Every 2 seconds it will increment the number in te text box.

First start the project from the form (form1 class is the startup object). The Form is displayed. Now push the button, this will create the
TimerThread.
You now see nicely that the number increments every 2 seconds.

Now start the application from the class (class1 is the startup
object). Now the TimerThread will be created in the Class1 object.
You will see that the number is never incremented.

When stepping through the code you will see that the TestThread method

is called.
The TestThread code in the form properly detects that this is run from a second thread (line InvokeRequired) and continues to the line where Invoke is called. I use Invole so that the increment function would run on the forms thread. It is here where the application seems to hang. The

number in
the textbox is never incremented.

Can anyone explain me why this is happening or how to solve this ?
i was wondering, might this have something to do with

Apparementthrea ding
?
(this is used when you start the application from the form (=startup
object)).
Maybe when you start it from the class this is no longer the case ?
Maybe it's something completely different.
Thanks for shedding some light in the darkness.

Regards, Serge

http://csharp.web1000.com/



Nov 15 '05 #5
ok, got it

I now have my application working with the message pump running (using the
Application.Run ) and my worker thread that I am able to configure
differently for each application (but re-using the status window)

Thanks VERY much !!!

"100" <10*@100.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Hi Serge,
Yes, you are right. The code after Application Run will be executed only
after the main window (passed to Run method) as a parameter is closed. In
this case when the application is closed. You cannot have alive windwos in
Windwos without messeage loop to dispatch messages to it. What I want to say is all GUI applications has to have at least one UI thread (for windows
forms this is thread that eventually calls Application.Run ) All UI
commponents has to be created by an UI thread.
What you might want to do in your case is to have 2 threads: one worker
thread and one UI thread to dispalay the status. See my code below.
The changes are:
1. I removed the Main method from Form1 class. We don't need it anymore.
2. I Added two new methods in Form1 class: Run and CloseForm(It could be
just Close, but I had to hide the base one).
3. Modified Class1's Main method.
4. I use the old timer to update the status form, but you can use whatever
fits better with your needs. The only things is that the changes you make to any UI components has to be made by the UI thread owning the component.
Which means that all threads but the UI thread itself has to use
Control.Invoke method.
//-------------------- Form1.cs -------------------------------//
using System;
using System.Drawing;
using System.Collecti ons;
using System.Componen tModel;
using System.Windows. Forms;
using System.Data;
using System.Threadin g;

namespace _ThreadTest
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows. Forms.Form
{
public System.Windows. Forms.Button button1;
private System.Windows. Forms.TextBox txtForm;
private System.Windows. Forms.Label label1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.Componen tModel.Containe r components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeCompo nent();

//
// TODO: Add any constructor code after InitializeCompo nent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Disp ose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.txtForm = new System.Windows. Forms.TextBox() ;
this.button1 = new System.Windows. Forms.Button();
this.label1 = new System.Windows. Forms.Label();
this.SuspendLay out();
//
// txtForm
//
this.txtForm.En abled = false;
this.txtForm.Lo cation = new System.Drawing. Point(8, 8);
this.txtForm.Na me = "txtForm";
this.txtForm.Si ze = new System.Drawing. Size(48, 20);
this.txtForm.Ta bIndex = 0;
this.txtForm.Te xt = "0";
this.txtForm.Te xtAlign = System.Windows. Forms.Horizonta lAlignment.Cent er; //
// button1
//
this.button1.Lo cation = new System.Drawing. Point(128, 8);
this.button1.Na me = "button1";
this.button1.Si ze = new System.Drawing. Size(192, 24);
this.button1.Ta bIndex = 1;
this.button1.Te xt = "Start Thread In Form Code - OK";
this.button1.Cl ick += new System.EventHan dler(this.butto n1_Click);
//
// label1
//
this.label1.Fon t = new System.Drawing. Font("Microsoft Sans Serif",
7.764706F, System.Drawing. FontStyle.Bold, System.Drawing. GraphicsUnit.Po int, ((System.Byte)( 0)));
this.label1.Loc ation = new System.Drawing. Point(128, 8);
this.label1.Nam e = "label1";
this.label1.Siz e = new System.Drawing. Size(184, 24);
this.label1.Tab Index = 2;
this.label1.Tex t = "Thread started from code = BAD";
//
// Form1
//
this.AutoScaleB aseSize = new System.Drawing. Size(5, 13);
this.ClientSize = new System.Drawing. Size(336, 36);
this.Controls.A dd(this.button1 );
this.Controls.A dd(this.txtForm );
this.Controls.A dd(this.label1) ;
this.Name = "Form1";
this.Text = "Increment every 2 ses - thread test";
this.ResumeLayo ut(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
public void Run()
{
Thread uiThread = new Thread(new ThreadStart(Sta tusThreadProc)) ;
uiThread.Apartm entState = ApartmentState. STA;
uiThread.Start( );
}
public void CloseForm()
{
if(InvokeRequir ed)
{
this.Invoke(new MethodInvoker(C loseForm));
}
this.Close();
}
/// <summary>Star ts message loop (this thread is UI thread.)</summary>
public void StatusThreadPro c()
{
Application.Run (this);
}

private void button1_Click(o bject sender, System.EventArg s e)
{
// Create the delegate that invokes methods for the timer.
TimerCallback timerDelegate = new TimerCallback(T estThread);

// Create a timer that waits one second, then invokes every second.
System.Threadin g.Timer timer = new System.Threadin g.Timer( timerDelegate, "nothing" ,1000, 2000);

}

public void TestThread(obje ct state)
{
if (! this.InvokeRequ ired )
{
base.Refresh();
txtForm.Text = (int.Parse(txtF orm.Text) + 1).ToString();
}
else
{
Invoke(new WaitCallback(Te stThread), new object[] {state});
}
}
}
}
//-------------------------------
Class1.cs ----------------------------------------
using System;
using System.Threadin g;
namespace _ThreadTest
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public class Class1
{
private static Form1 _frmStatus;
private static TimerCallback timerDelegate;
private static System.Threadin g.Timer timer;
public Class1()
{
}

[STAThread]
static void Main(string[] args)
{

_frmStatus = new Form1();
_frmStatus.butt on1.Visible = false;
_frmStatus.Run( );

// Create the delegate that invokes methods for the timer.
timerDelegate = new TimerCallback(_ frmStatus.TestT hread);

// Create a timer that waits one second, then invokes every second.
timer = new System.Threadin g.Timer( timerDelegate, "nothing" ,1000,
10000);
for(int i = 0; i < 20; i++)
{
//Do some job
Thread.Sleep(10 00);
}
//Stop the close the status form. (This will exit the UI thread).
_frmStatus.Clos eForm();

//You can do more work here

}
}
}
HTH
B\rgds
100

Nov 15 '05 #6

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

Similar topics

2
2498
by: Bruce Bon | last post by:
The class below is intended to play a Sun audio file (.au) in the background while the main thread, which is servicing a GUI, continues without impact. It doesn't work. For a sound file that takes 3-5 seconds to play, the main thread hangs for that long. I have run this many times, with changes in printouts and insertion of strategic sleeps to try to make sure that the player thread gives up control, but apparently the call to...
1
2016
by: Rasmusson, Lars | last post by:
Hi, I have a problem doing I/O in a python thread. I want a thread to execute a command using os.popen, read its input until the end, and then print 'DONE' and terminate. However, the thread hangs when it reaches the end of the stream.
3
1806
by: Philippe C. Martin | last post by:
Hi, I need to pop-up in a "modless" manner some windows from an existing Tkinter loop. The following code works OK under Linux: the second window opens, shows the information, and quits cleanly when destroyed. However, under windows, I get the second window without the content (so I hang in run I guess), and both the thread and the calling process hang. Any clue ?
0
1283
by: pawo | last post by:
Hello everyone, I'm a perl beginner. I created a piece of code starting a first thread which in turn creates a second thread. Unfortunately the creation of the second thread hangs the first one. Is there anybody who knows what's going on ?. I decided to create fully OO software and I wouldn't like to go back into a fork-based solution. I also included my test application (I know there are no joins but it's only for testing purposes)
1
3948
by: Serge | last post by:
Hi, I am having some lock up problems in my c# code. when from a 2nd thread (worker thread) i call a normal standard function like Trace.WriteLine the 2nd thread freezes/hangs. The 2nd thread is started with a normal threadstart, etc. When looking on the internet I found some articles that hangs can be caused by unmanaged threads but I don't think I am doing this (am not using coms, .... )
4
6359
by: Marc Missire | last post by:
Hi, I have an issue below I'd love help with, involving a static variable, Application_Start, and a background thread. In global.asax.cs I have a static variable (outside any method) with a default value, such as: private static string serverName = string.Empty;
1
1943
by: Toon Verstraelen | last post by:
Hi, I recently had a thread problem and I could reduce it to a very short example that shows the problem. I hope it has its origin in my misunderstanding of how python threads work. Here it is: --- my_thread.py --- import threading from subprocess import Popen, PIPE, STDOUT
11
8688
by: HairlipDog58 | last post by:
Hello, There are several 'cross-thread operation not valid' exception postings in the MSDN discussion groups, but none address my exact situation. I have authored a .NET component in Visual C# .NET 2003 that is capable of firing several types of events to notify user of errors, data changes, etc. The component uses a thread to perform background communications and if there is an error or data-change fires an event to notify the user....
4
15887
by: Mufasa | last post by:
Is there any way to force a thread to abort and really have it abort? I have a thread that every once in a while gets hung to so I kill it. Problem is I have a thread that every once in a while gets stuck (I'm working on why that happens) and I want to kill it. I do a thread.abort and the status becomes abortrequested but never actually goes through. If it were an actual process I could kill it but there seems to be no real kill for...
0
9522
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
10111
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
9948
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...
0
9765
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...
0
8770
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...
1
7327
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
6603
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
3866
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
3
2738
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.