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

C#

 
GeneralRe: C# & XML & nested loops problem (try 2) Pin
Anonymous12-Apr-05 2:38
Anonymous12-Apr-05 2:38 
GeneralC# & XML & nested loops problem Pin
Anonymous12-Apr-05 1:45
Anonymous12-Apr-05 1:45 
GeneralRe: C# & XML & nested loops problem Pin
Ian Bowler12-Apr-05 7:45
Ian Bowler12-Apr-05 7:45 
GeneralRe: C# & XML & nested loops problem Pin
Anonymous12-Apr-05 23:31
Anonymous12-Apr-05 23:31 
GeneralProb with creating user control Pin
Anonymous12-Apr-05 1:03
Anonymous12-Apr-05 1:03 
GeneralRe: Prob with creating user control Pin
Judah Gabriel Himango12-Apr-05 4:38
sponsorJudah Gabriel Himango12-Apr-05 4:38 
Generalon Signed Assemblies in .Net Pin
ppp00112-Apr-05 0:29
ppp00112-Apr-05 0:29 
GeneralThreading.Timer callback called multiple times Pin
sjhart12-Apr-05 0:23
sjhart12-Apr-05 0:23 
Hi all,

I have a scheduler application, running as a windows service.

This application generates a Threading.Timer for each process with a callback called OnTimedEvent().

What is happening is that if two processes are scheduled at the same time, one of the processes may enter OnTimedEvent() multiple times (the current record is 10).

Threading.Timers were used as there is a bug with the System.Timers whereby if two events are scheduled at the same time one won't fire at all. This is a known issue and I was advised by Microsoft to use the Threading.Timers.

Does anybody know if it is possible to prevent this. I initially thought that multiple threads might be being created, but logging the thread id indicates that it is a single thread per scheduled item, and that single thread is entering the OnTimedEvent callback multiple times per event.

I tried a mutex at the start of the callback i.e.

public void OnTimedEvent(object objSource)
{
if(!m_mtxEvent.WaitOne(1, false))
{
Thread.Sleep(1500);
return;
}

lock(this)
{
// Do some processing here
}
}

Adding the Thread.Sleep(1500) line seemed to reduce the problem, but not eliminate it.


I knew I should have stuck to C++
GeneralRe: Threading.Timer callback called multiple times Pin
Mike Dimmick12-Apr-05 2:43
Mike Dimmick12-Apr-05 2:43 
GeneralRe: Threading.Timer callback called multiple times Pin
sjhart12-Apr-05 3:05
sjhart12-Apr-05 3:05 
GeneralC#, COM & Type Libraries Pin
MrEyes12-Apr-05 0:13
MrEyes12-Apr-05 0:13 
Questionhow to send http streams in c# Pin
arusmemon11-Apr-05 23:53
arusmemon11-Apr-05 23:53 
AnswerRe: how to send http streams in c# Pin
Claudio Grazioli12-Apr-05 3:05
Claudio Grazioli12-Apr-05 3:05 
GeneralRe: Setting file attributes Pin
hooray12-Apr-05 1:10
hooray12-Apr-05 1:10 
GeneralUnsafe code on a webserver - 2bpp images Pin
Mark Otway11-Apr-05 23:39
Mark Otway11-Apr-05 23:39 
GeneralRe: Unsafe code on a webserver - 2bpp images Pin
Mark Otway12-Apr-05 20:38
Mark Otway12-Apr-05 20:38 
GeneralError in DataBinding after DataSet.Clear() Pin
Vexta11-Apr-05 21:47
Vexta11-Apr-05 21:47 
GeneralCheckbox Controls in a form Pin
Billy Whizz11-Apr-05 21:02
Billy Whizz11-Apr-05 21:02 
GeneralRe: Checkbox Controls in a form Pin
Dave Kreskowiak12-Apr-05 7:02
mveDave Kreskowiak12-Apr-05 7:02 
GeneralConvert string to a string array Pin
myNameIsRon11-Apr-05 19:29
myNameIsRon11-Apr-05 19:29 
GeneralRe: Convert string to a string array Pin
Robert Rohde11-Apr-05 19:41
Robert Rohde11-Apr-05 19:41 
GeneralRe: Convert string to a string array Pin
myNameIsRon11-Apr-05 19:56
myNameIsRon11-Apr-05 19:56 
GeneralRe: Convert string to a string array Pin
techieboi12-Apr-05 5:33
techieboi12-Apr-05 5:33 
GeneralI need advice on class design Pin
tantiboh11-Apr-05 19:12
tantiboh11-Apr-05 19:12 
GeneralRe: I need advice on class design Pin
Christian Graus11-Apr-05 19:26
protectorChristian Graus11-Apr-05 19:26 

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.