Click here to Skip to main content
15,893,486 members
Home / Discussions / C#
   

C#

 
GeneralRe: Same Random Numbers Pin
humayunlalzad14-Jul-08 6:28
humayunlalzad14-Jul-08 6:28 
AnswerRe: Same Random Numbers Pin
Paul Conrad14-Jul-08 7:00
professionalPaul Conrad14-Jul-08 7:00 
AnswerRe: Same Random Numbers Pin
Robert.C.Cartaino14-Jul-08 11:52
Robert.C.Cartaino14-Jul-08 11:52 
GeneralRe: Same Random Numbers Pin
humayunlalzad14-Jul-08 18:42
humayunlalzad14-Jul-08 18:42 
Questionloop break on KeyDown [modified] Pin
erfi14-Jul-08 5:21
erfi14-Jul-08 5:21 
AnswerRe: loop break on KeyDown Pin
Harvey Saayman14-Jul-08 5:25
Harvey Saayman14-Jul-08 5:25 
AnswerRe: loop break on KeyDown Pin
paas14-Jul-08 6:44
paas14-Jul-08 6:44 
AnswerRe: loop break on KeyDown Pin
Frank Horn14-Jul-08 8:08
Frank Horn14-Jul-08 8:08 
What excactly are you trying to achieve? Is it that once the user has pressed the escape key, you want the application to terminate as soon as possible? Or do you have a longish OnPaint method which you want interrupted when the escape key is pressed?

The first would be much easier. The second I think cannot work without polling for the EXIT variable within the OnPaint procedure everywhere it could be interrupted, and even then I'm not sure it could work. A call to Application.DoEvents won't help cause in OnPaint you're right within handling the windows message queue and have to finish the loop anyway. The keyboard action only puts a message to the end of your form's message queue, which will not be processed before you leave the OnPaint method. Either you do some crazy unmanaged subclassing, or you split your painting logic into "atomic" operations which you instigate (via this.BeginInvoke) from a different thread. In this thread you can capture the EXIT flag set by the main thread via the escape key and if it's true stop pouring BeginInvoke(PaintNextPart) delegates to the main thread.

You need a little more then, of course, and a firm grip of threading and locking mechanisms, or you'll freeze your form.
QuestionQuick search with datagrid & textbox! Pin
Yosh_14-Jul-08 5:03
professionalYosh_14-Jul-08 5:03 
AnswerRe: Quick search with datagrid & textbox! Pin
paas14-Jul-08 6:49
paas14-Jul-08 6:49 
GeneralRe: Quick search with datagrid & textbox! Pin
Yosh_17-Jul-08 6:47
professionalYosh_17-Jul-08 6:47 
GeneralRe: Quick search with datagrid & textbox! Pin
paas18-Jul-08 2:59
paas18-Jul-08 2:59 
QuestionStarting explorer Pin
ajtunbridge14-Jul-08 4:52
ajtunbridge14-Jul-08 4:52 
AnswerRe: Starting explorer Pin
DaveyM6914-Jul-08 5:19
professionalDaveyM6914-Jul-08 5:19 
AnswerRe: Starting explorer Pin
TheFM23414-Jul-08 6:58
TheFM23414-Jul-08 6:58 
GeneralRe: Starting explorer Pin
ajtunbridge14-Jul-08 8:49
ajtunbridge14-Jul-08 8:49 
QuestionDecimal symbol in Regional settings [modified] Pin
serega2007us14-Jul-08 4:13
serega2007us14-Jul-08 4:13 
AnswerRe: Decimal symbol in Regional settings Pin
DaveyM6914-Jul-08 4:31
professionalDaveyM6914-Jul-08 4:31 
GeneralRe: Decimal symbol in Regional settings Pin
serega2007us14-Jul-08 4:40
serega2007us14-Jul-08 4:40 
QuestionMemory Exception while saving an image Pin
DeepOceans14-Jul-08 3:59
DeepOceans14-Jul-08 3:59 
AnswerRe: Memory Exception while saving an image Pin
Alan Balkany14-Jul-08 4:03
Alan Balkany14-Jul-08 4:03 
QuestionGetting command line params in a windows forms app Pin
GreatBarrier8614-Jul-08 3:45
GreatBarrier8614-Jul-08 3:45 
AnswerRe: Getting command line params in a windows forms app Pin
Harvey Saayman14-Jul-08 3:52
Harvey Saayman14-Jul-08 3:52 
GeneralRe: Getting command line params in a windows forms app Pin
GreatBarrier8614-Jul-08 3:53
GreatBarrier8614-Jul-08 3:53 
GeneralRe: Getting command line params in a windows forms app Pin
Harvey Saayman14-Jul-08 4:01
Harvey Saayman14-Jul-08 4:01 

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.