Click here to Skip to main content
15,891,943 members
Home / Discussions / C#
   

C#

 
GeneralRe: RSS Aggregator Pin
mil_an6-Apr-04 13:17
mil_an6-Apr-04 13:17 
Generalusing try,catch exceptions in a thread timer Pin
User 9625786-Apr-04 12:02
User 9625786-Apr-04 12:02 
GeneralRe: using try,catch exceptions in a thread timer Pin
Heath Stewart6-Apr-04 12:29
protectorHeath Stewart6-Apr-04 12:29 
GeneralRe: using try,catch exceptions in a thread timer Pin
User 9625786-Apr-04 15:27
User 9625786-Apr-04 15:27 
GeneralRe: using try,catch exceptions in a thread timer Pin
Roman Rodov6-Apr-04 17:14
Roman Rodov6-Apr-04 17:14 
GeneralRe: using try,catch exceptions in a thread timer Pin
User 9625786-Apr-04 19:48
User 9625786-Apr-04 19:48 
GeneralRe: using try,catch exceptions in a thread timer Pin
User 9625786-Apr-04 19:52
User 9625786-Apr-04 19:52 
GeneralRe: using try,catch exceptions in a thread timer Pin
Heath Stewart7-Apr-04 3:08
protectorHeath Stewart7-Apr-04 3:08 
Then apartently your not catching exceptions in the right place or aren't catching the right exceptions. I know you put Exception in your sample code in the root message of this thread, but I've seen many times where people don't sample their code accurately.

The other problem is that all the timers (and pretty much everything in System.Threading) encapsulate native APIs. If a thread throws an exception in the native API, the timer thread will most likely quit. In your catch block, restart the timer by instantiating a new Timer, assigning it to the previous field (if any) and using the same TimerCallback delegate.

Also, you should consider using System.Timers.Timer instead, which has higher resolution and is pretty well guarded against exceptions (it still throws them, but typically recovers the timer thread).

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: using try,catch exceptions in a thread timer Pin
User 9625787-Apr-04 6:56
User 9625787-Apr-04 6:56 
GeneralListView with GroupView enabled and thousands of items Pin
georgestrajan6-Apr-04 11:58
georgestrajan6-Apr-04 11:58 
GeneralRe: ListView with GroupView enabled and thousands of items Pin
Heath Stewart6-Apr-04 12:27
protectorHeath Stewart6-Apr-04 12:27 
GeneralRe: ListView with GroupView enabled and thousands of items Pin
georgestrajan7-Apr-04 17:56
georgestrajan7-Apr-04 17:56 
GeneralRe: ListView with GroupView enabled and thousands of items Pin
Heath Stewart7-Apr-04 18:02
protectorHeath Stewart7-Apr-04 18:02 
GeneralCompare two dates. Pin
kornstyle6-Apr-04 11:34
kornstyle6-Apr-04 11:34 
GeneralRe: Compare two dates. Pin
Heath Stewart6-Apr-04 12:21
protectorHeath Stewart6-Apr-04 12:21 
GeneralRe: Compare two dates. Pin
sreejith ss nair6-Apr-04 20:36
sreejith ss nair6-Apr-04 20:36 
GeneralMessage Removed Pin
6-Apr-04 11:23
wibblewibblewibble6-Apr-04 11:23 
GeneralRe: double [] via tcp/ip Pin
Heath Stewart6-Apr-04 12:19
protectorHeath Stewart6-Apr-04 12:19 
GeneralEncapsulating properties as nested class Pin
Enrico Angkawijaya6-Apr-04 11:16
Enrico Angkawijaya6-Apr-04 11:16 
GeneralAuthentication with back-end DB Pin
mil_an6-Apr-04 7:18
mil_an6-Apr-04 7:18 
GeneralRe: Authentication with back-end DB Pin
Heath Stewart6-Apr-04 10:39
protectorHeath Stewart6-Apr-04 10:39 
GeneralArray and related collections. Pin
HAHAHA_NEXT6-Apr-04 6:28
HAHAHA_NEXT6-Apr-04 6:28 
GeneralRe: Array and related collections. Pin
Judah Gabriel Himango6-Apr-04 6:37
sponsorJudah Gabriel Himango6-Apr-04 6:37 
GeneralRe: Array and related collections. Pin
Heath Stewart6-Apr-04 6:42
protectorHeath Stewart6-Apr-04 6:42 
GeneralRe: Array and related collections. Pin
HAHAHA_NEXT6-Apr-04 7:07
HAHAHA_NEXT6-Apr-04 7:07 

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.