Click here to Skip to main content
15,887,386 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questionhow to solve client machine crystal report error?? Pin
ranipriya 201027-May-08 3:05
ranipriya 201027-May-08 3:05 
RantRe: how to solve client machine crystal report error?? Pin
jzonthemtn27-May-08 9:05
jzonthemtn27-May-08 9:05 
AnswerCP Ignore: Repeat Offender Pin
leckey27-May-08 14:35
leckey27-May-08 14:35 
QuestionWindows Service - The service "started and then stopped" ?! Pin
007jb27-May-08 3:03
007jb27-May-08 3:03 
AnswerRe: Windows Service - The service "started and then stopped" ?! Pin
Christian Graus27-May-08 3:16
protectorChristian Graus27-May-08 3:16 
GeneralRe: Windows Service - The service "started and then stopped" ?! Pin
007jb27-May-08 3:46
007jb27-May-08 3:46 
GeneralRe: Windows Service - The service "started and then stopped" ?! Pin
Rob Smiley27-May-08 6:27
Rob Smiley27-May-08 6:27 
AnswerRe: Windows Service - The service "started and then stopped" ?! Pin
Peter Josefsson Sweden27-May-08 15:30
Peter Josefsson Sweden27-May-08 15:30 
Hi!

Some thoughts/experiences with services:

1. You can't use message boxes (or any other form of user interaction) from services (unless you check the "allow service to interact with desktop" in the service manager, but that is very bad practice). Use the event log instead (see the example in the documentation for System.ServiceProcess.ServiceBase class in the framework class library). This is probably what causes your service to crash. Make sure neither your service nor the libraries you use rely on user interaction.

2. The System.Threading.Timer class is the right one to use in a service (the Windows Forms timers don't work - they rely on the window message pump, which doesn't exist in a service), but beware that it doesn't work like the Windows Forms timer: Among other things, it continues to fire events even when one is executing, so you have to do some synchronization (or disable and then reenable the timer) in Timer_Tick.

3. An exception on your worker thread (Timer_Tick) vanishes without a trace and the service doesn't stop because of it. Make Timer_Tick very small, containing only a try/catch block that logs any exceptions (and possibly does an Environment.FailFast if things look hopeless) and calls another member that does the actual work.

Hope this helped.

Peter the small turnip

(1) It Has To Work. --RFC 1925[^]

QuestionStart Up Code Pin
Jared774427-May-08 2:35
Jared774427-May-08 2:35 
AnswerRe: Start Up Code Pin
Christian Graus27-May-08 3:13
protectorChristian Graus27-May-08 3:13 
QuestionAppend or Insert the Text in Outlook 2003 message body using vb.net Pin
~Khatri Mitesh~27-May-08 0:28
~Khatri Mitesh~27-May-08 0:28 
QuestionPlease Help In VB 2008 Express Edition Pin
Abidh27-May-08 0:05
Abidh27-May-08 0:05 
AnswerRe: Please Help In VB 2008 Express Edition Pin
Ashfield27-May-08 1:23
Ashfield27-May-08 1:23 
GeneralRe: Please Help In VB 2008 Express Edition Pin
Abidh27-May-08 18:51
Abidh27-May-08 18:51 
GeneralRe: Please Help In VB 2008 Express Edition Pin
Ashfield27-May-08 23:15
Ashfield27-May-08 23:15 
GeneralRe: Please Help In VB 2008 Express Edition Pin
Abidh28-May-08 1:34
Abidh28-May-08 1:34 
GeneralRe: Please Help In VB 2008 Express Edition Pin
Ashfield28-May-08 5:03
Ashfield28-May-08 5:03 
QuestionError in Array Handling Pin
nagendrathecoder26-May-08 23:49
nagendrathecoder26-May-08 23:49 
AnswerRe: Error in Array Handling Pin
dan!sh 27-May-08 1:00
professional dan!sh 27-May-08 1:00 
AnswerRe: Error in Array Handling Pin
Chinners27-May-08 1:00
Chinners27-May-08 1:00 
AnswerRe: Error in Array Handling Pin
nagendrathecoder27-May-08 1:25
nagendrathecoder27-May-08 1:25 
QuestionProcess Time Pin
~V~26-May-08 20:36
~V~26-May-08 20:36 
AnswerRe: Process Time Pin
Ashfield26-May-08 21:14
Ashfield26-May-08 21:14 
GeneralRe: Process Time Pin
~V~26-May-08 21:35
~V~26-May-08 21:35 
GeneralRe: Process Time Pin
Mycroft Holmes26-May-08 22:24
professionalMycroft Holmes26-May-08 22:24 

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.