Click here to Skip to main content
15,884,099 members
Home / Discussions / C#
   

C#

 
GeneralRe: Assigning ICON to new file type (*.dtl) Pin
himuskanhere7-Sep-10 22:45
himuskanhere7-Sep-10 22:45 
QuestionIntroduction to C# application with SQL db Pin
Chesnokov Yuriy7-Sep-10 19:10
professionalChesnokov Yuriy7-Sep-10 19:10 
QuestionAccessing CANdb Database file in C# Pin
Niungareamit7-Sep-10 18:46
Niungareamit7-Sep-10 18:46 
AnswerRe: Accessing CANdb Database file in C# Pin
SeMartens8-Sep-10 0:09
SeMartens8-Sep-10 0:09 
AnswerRe: Accessing CANdb Database file in C# Pin
Dave Kreskowiak8-Sep-10 3:56
mveDave Kreskowiak8-Sep-10 3:56 
QuestionCase for .net remoting Pin
faheemnadeem7-Sep-10 15:45
faheemnadeem7-Sep-10 15:45 
AnswerRe: Case for .net remoting Pin
brunoseixas9-Sep-10 9:40
brunoseixas9-Sep-10 9:40 
QuestionDoEvents() and System.Threading.Timer Pin
Keith Vitali7-Sep-10 13:16
Keith Vitali7-Sep-10 13:16 
Hi everyone,

I am trying to update some UI periodically through the use of Application.DoEvents() in response to a timer callback. However, I am having a bit of trouble getting it to work.

So, I have a dialog box that is created in the main thread. I have a long running method in a third party control and all I want to do is make sure that the dialog box stays responsive to mouse movements and can respond to move events etc. I know I should be calling the long running function in a background thread but due to the idiosyncracies of the software design and third party tools, I am unable to do so.

So what I thought I would do is create a Threading.Timer object and have it send periodic events to my dialog box and ask the message queue to process the messages.

This scenario is as follows:
m_timer = new System.Threading.Timer(new TimerCallback(TimeElapsedHandler),
                                     null, System.Threading.Timeout.Infinite, 100);
m_timer.Change(0, 100); // Start timer


The timer handler is as follows:

private void TimeElapsedHandler(object state)
{   
    System.Windows.Forms.Application.DoEvents();
}


In the debug mode, I can see this event getting called during the processing. However, the DoEvents() call is not really updating the dialog box as it should.

Now, the strange thing is that when I add some Application.DoEvents() in the callbacks that I get from the third party call, the update is as I would expect it (I cannot rely on these updates to come frequently enough, hence I need a regular periodic solution).

The puzzling thing is that the timer and the dialog box is created on the main thread. So, I am puzzled as to why my update is not happening.

I would appreciate any thoughts or input you might have on this.

Best wishes,

Keith
AnswerRe: DoEvents() and System.Threading.Timer Pin
Keith Vitali7-Sep-10 13:45
Keith Vitali7-Sep-10 13:45 
AnswerRe: DoEvents() and System.Threading.Timer Pin
Luc Pattyn7-Sep-10 14:20
sitebuilderLuc Pattyn7-Sep-10 14:20 
GeneralRe: DoEvents() and System.Threading.Timer Pin
Keith Vitali8-Sep-10 0:34
Keith Vitali8-Sep-10 0:34 
GeneralRe: DoEvents() and System.Threading.Timer Pin
Luc Pattyn8-Sep-10 0:45
sitebuilderLuc Pattyn8-Sep-10 0:45 
QuestionWould like a blank string as default vaule for a combo box that is bound Pin
BraveKnightFSJ7-Sep-10 9:44
BraveKnightFSJ7-Sep-10 9:44 
AnswerRe: Would like a blank string as default vaule for a combo box that is bound Pin
Pete O'Hanlon7-Sep-10 12:23
mvePete O'Hanlon7-Sep-10 12:23 
GeneralRe: Would like a blank string as default vaule for a combo box that is bound Pin
BraveKnightFSJ7-Sep-10 12:41
BraveKnightFSJ7-Sep-10 12:41 
GeneralRe: Would like a blank string as default vaule for a combo box that is bound Pin
Pete O'Hanlon7-Sep-10 12:45
mvePete O'Hanlon7-Sep-10 12:45 
QuestionSorting a somewhat unknown list of properties Pin
MollyTheCoder7-Sep-10 4:25
MollyTheCoder7-Sep-10 4:25 
AnswerRe: Sorting a somewhat unknown list of properties Pin
Ian Shlasko7-Sep-10 5:50
Ian Shlasko7-Sep-10 5:50 
GeneralRe: Sorting a somewhat unknown list of properties Pin
MollyTheCoder7-Sep-10 6:43
MollyTheCoder7-Sep-10 6:43 
GeneralRe: Sorting a somewhat unknown list of properties Pin
Ian Shlasko7-Sep-10 7:36
Ian Shlasko7-Sep-10 7:36 
GeneralRe: Sorting a somewhat unknown list of properties Pin
MollyTheCoder7-Sep-10 11:15
MollyTheCoder7-Sep-10 11:15 
GeneralRe: Sorting a somewhat unknown list of properties Pin
Ian Shlasko7-Sep-10 11:45
Ian Shlasko7-Sep-10 11:45 
GeneralRe: Sorting a somewhat unknown list of properties Pin
AspDotNetDev7-Sep-10 13:12
protectorAspDotNetDev7-Sep-10 13:12 
QuestionHow to print in Windows CE Pin
Medo-I7-Sep-10 3:55
Medo-I7-Sep-10 3:55 
AnswerRe: How to print in Windows CE Pin
OriginalGriff7-Sep-10 5:29
mveOriginalGriff7-Sep-10 5:29 

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.