Click here to Skip to main content
15,914,071 members
Home / Discussions / C#
   

C#

 
AnswerRe: execting .bat file. Pin
Ed.Poore19-Jun-06 10:33
Ed.Poore19-Jun-06 10:33 
AnswerRe: execting .bat file. Pin
Joshua Lunsford19-Jun-06 10:33
Joshua Lunsford19-Jun-06 10:33 
AnswerRe: execting .bat file. Pin
Spike^Blue^Heaven19-Jun-06 20:13
Spike^Blue^Heaven19-Jun-06 20:13 
GeneralRe: execting .bat file. Pin
tom laz19-Jun-06 10:46
tom laz19-Jun-06 10:46 
GeneralRe: execting .bat file. Pin
tom laz19-Jun-06 10:49
tom laz19-Jun-06 10:49 
GeneralRe: execting .bat file. Pin
Joshua Lunsford19-Jun-06 11:28
Joshua Lunsford19-Jun-06 11:28 
QuestionWindows Service with threading issues Pin
Joshua Lunsford19-Jun-06 10:26
Joshua Lunsford19-Jun-06 10:26 
AnswerRe: Windows Service with threading issues Pin
Tom Delany19-Jun-06 11:47
Tom Delany19-Jun-06 11:47 
We have a similar situation, and basically, in our thread classes, we have created a Shutdown() method.

The threads themselves this method at different points in their loops (where it is practical for them to gracefully stop), and simply shut themselves down when this method returns true. The threads do not stop immediately, like from a Thread.Abort(), but this way they are given a chance to terminate gracefully.

In the thread proc, the method is coded as so:

public class SomeThread
{

// This variable is used by multiple threads, so it must be thread-safe.
// Do not access it directly -- use the ShutDown property instead.
private bool m_bTimeToShutdown = false;
private Object ShutDownLock = new Object();

// Other variables and methods go here......

/// <summary>
/// This property can be set to tell the main loop to stop processing.
/// The main loop continues to run as long as this property is false.
/// </summary>

public bool ShutDown {
get {
bool rslt;
lock (ShutDownLock) {
rslt = m_bTimeToShutdown;
}
return rslt;
}
set {
lock (ShutDownLock) {
m_bTimeToShutdown = value;
}
}
}
}

Calling example (in the Main service):

/// <summary>
/// Stop this service.
/// </summary>
protected override void OnStop()
{
// TODO: Add code here to perform any tear-down necessary to stop your service.
log.Info("Shutting down some thread"); // This is just a sample logging call.
SomeThreadThrdProc.ShutDown = true;
}

I hope this helps you.

Tom Delany
QuestionPageSize not working on PagedDataSource populated by an ArrayList Pin
Afut19-Jun-06 9:07
Afut19-Jun-06 9:07 
QuestionNeural networks in c# Pin
yasar khan19-Jun-06 8:35
yasar khan19-Jun-06 8:35 
AnswerRe: Neural networks in c# Pin
Josh Smith19-Jun-06 9:58
Josh Smith19-Jun-06 9:58 
Question.NET 2.0 properties and Javascript Pin
Marc Clifton19-Jun-06 7:59
mvaMarc Clifton19-Jun-06 7:59 
AnswerRe: .NET 2.0 properties and Javascript Pin
Marc Clifton19-Jun-06 9:25
mvaMarc Clifton19-Jun-06 9:25 
QuestionCombo Box and refresh/reload data Pin
Saamir19-Jun-06 7:45
Saamir19-Jun-06 7:45 
AnswerRe: Combo Box and refresh/reload data Pin
Paul Brower19-Jun-06 9:31
Paul Brower19-Jun-06 9:31 
QuestionRe: Combo Box and refresh/reload data Pin
Saamir19-Jun-06 10:14
Saamir19-Jun-06 10:14 
GeneralRe: Combo Box and refresh/reload data Pin
Saamir20-Jun-06 5:16
Saamir20-Jun-06 5:16 
QuestionHow to Count number of specific day Pin
rockxuyenmandem19-Jun-06 7:36
rockxuyenmandem19-Jun-06 7:36 
AnswerRe: How to Count number of specific day Pin
LongRange.Shooter19-Jun-06 7:51
LongRange.Shooter19-Jun-06 7:51 
AnswerRe: How to Count number of specific day Pin
Tom Delany20-Jun-06 4:49
Tom Delany20-Jun-06 4:49 
QuestionAutomating Word to Fill in a Word Template Pin
vnoga19-Jun-06 7:34
vnoga19-Jun-06 7:34 
AnswerRe: Automating Word to Fill in a Word Template Pin
vnoga19-Jun-06 8:14
vnoga19-Jun-06 8:14 
QuestionTextarea - Multiple data submission Pin
edgtr19-Jun-06 5:59
edgtr19-Jun-06 5:59 
AnswerRe: Textarea - Multiple data submission Pin
LongRange.Shooter19-Jun-06 7:58
LongRange.Shooter19-Jun-06 7:58 
Questionclass to be both marked with the serializable attribute and extend MarshalByRefObject [modified] Pin
Kiran Kumar Singani19-Jun-06 3:14
Kiran Kumar Singani19-Jun-06 3:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.