Click here to Skip to main content
15,894,017 members
Home / Discussions / C#
   

C#

 
Questionexecting .bat file. Pin
tom laz19-Jun-06 10:29
tom laz19-Jun-06 10:29 
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 
I have an issue with stopping threads in a windows service application I was wondering if anyone can help. let me set it up for you. In a windows service you have to use the OnStart method to initialize your application... but you cannot run any loops or sequence of events that contain loops or the state of the application will be in an "starting" service mode indefinitely. So I start a thread call Maint to handle the application. The application has threee main functions at the moment that interface with WAN file shares and a sql db. I run these parallel each in there own thread(and they dont interact with eachother). so in the OnStart method:

maint Maint = new maint();<br />
maintThread = new Thread(new ThreadStart(Maint.start));<br />
maintThread.Start();

in that start method i call:

importassets ia = new importassets();<br />
importThread = new Thread(new ThreadStart(ia.importasset));<br />
importThread.Start();<br />
<br />
updatereg ur = new updatereg();<br />
updateThread = new Thread(new ThreadStart(ur.runupdate));<br />
updateThread.Start();<br />
<br />
forcelogins fl = new forcelogins();<br />
loginThread = new Thread(new ThreadStart(fl.runlogins));<br />
loginThread.Start();<br />
<br />
//This section forces the importThread to restart hourly<br />
int startTime = System.Environment.TickCount; <br />
int runTime = startTime+3600000;<br />
while(true)<br />
{<br />
	int nowTime = System.Environment.TickCount;<br />
	FAISservice fs = new FAISservice();<br />
	if(!fs.isRunning)<br />
		break;<br />
	if(runTime < nowTime)<br />
	{<br />
		importThread.Abort();<br />
		Thread.Sleep(3000);<br />
		startImport();<br />
		runTime = nowTime+3600000;<br />
	}<br />
	Thread.Sleep(10000);<br />
<br />
}


Now, all works fine until the OnStop() method gets called by the service being stopped or restarted. in the OnStop() method i run:

isRunning = false;<br />
<br />
maintThread.Abort();<br />
<br />
maint Maint = new maint();<br />
Maint.stop();


and in the stop() method i call:
importThread.Abort();<br />
			updateThread.Abort();<br />
			loginThread.Abort();


Now I'm locked in a "STOPPING" state and i have to kill the process... any clues? also... my above 3 threads start while(true) loops that only BREAK when isRunning=false.
AnswerRe: Windows Service with threading issues Pin
Tom Delany19-Jun-06 11:47
Tom Delany19-Jun-06 11:47 
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 

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.