Re: [BLACKBOX] Long running command and Dialog.ShowStatus

From: [at]} <Treutwein>
Date: Tue, 8 Dec 2009 09:44:43 +0100

----boundary-LibPST-iamunique-2020660867_-_-
Content-type: text/plain

the KeyboardWatcher thread has some precautions for a non-responsive window,
which I don't fully understand. Maybe the logic of KeyboardWatcher needs some
polishing ...

I am puzzled by the

        WinApi.Sleep(1)

MSDN says:

        A value of zero causes the thread to relinquish the remainder of its
time
        slice to any other thread of equal priority that is ready to run. If
there
        are no other threads of equal priority ready to run, the function
returns
        immediately, and the thread continues execution.

[...]

Remarks

This function causes a thread to relinquish the remainder of its time slice
and become unrunnable for an interval based on the value of dwMilliseconds.
The system clock "ticks" at a constant rate. If dwMilliseconds is less than
the resolution of the system clock, the thread may sleep for less than the
specified length of time. If dwMilliseconds is greater than one tick but less
than two, the wait can be anywhere between one and two ticks, and so on. To
increase the accuracy of the sleep interval, call the timeGetDevCaps function
to determine the supported minimum timer resolution and the timeBeginPeriod
function to set the timer resolution to its minimum. Use caution when calling
timeBeginPeriod, as frequent calls can significantly affect the system clock,
system power usage, and the scheduler. If you call timeBeginPeriod, call it
one time early in the application and be sure to call the timeEndPeriod
function at the very end of the application.

After the sleep interval has passed, the thread is ready to run. If you
specify 0 milliseconds, the thread will relinquish the remainder of its time
slice but remain ready. Note that a ready thread is not guaranteed to run
immediately. Consequently, the thread may not run until some time after the
sleep interval elapses. For more information, see Scheduling Priorities.



See http://msdn.microsoft.com/en-us/library/ms686298(VS.85).aspx

--
  Bernhard 
> -----Original Message-----
> From: BlackBox [mailto:BLACKBOX{([at]})nowhere.xy> Josef Templ
> Sent: Friday, December 04, 2009 12:35 PM
> To: BLACKBOX{([at]})nowhere.xy> Subject: Re: [BLACKBOX] Long running command and Dialog.ShowStatus
> 
> 
> > There is a second thread in the BB system that is used to 
> interrupt a
> > buggy loop.  I think it recognizes the break key.  This thread runs
> > every second or so.
> 
> 
> Indeed! Thanks for the hint.
> 
> By the way, it is Ctrl-Break 
> or for the germans Strg-Pause.
> 
> 
> - Josef
> 
> 
> ----
> To unsubscribe, send a message with body "SIGNOFF BLACKBOX" 
> to LISTSERV{([at]})nowhere.xy> 
----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-2020660867_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwIHRoZSBLZXlib2FyZFdhdGNoZXIgdGhyZWFkIGhh
cyBzb21lIHByZWNhdXRpb25zIGZvciBhIG5vbi1yZXNwb25zaXZlIHdpbmRvdyxccGFyDQp3aGlj
aCBJIGRvbid0IGZ1bGx5IHVuZGVyc3RhbmQuIE1heWJlIHRoZSBsb2dpYyBvZiBLZXlib2FyZFdh
dGNoZXIgbmVlZHMgc29tZVxwYXINCnBvbGlzaGluZyAuLi5ccGFyDQpccGFyDQpJIGFtIHB1enps
ZWQgYnkgdGhlIFxwYXINClxwYXINClx0YWIgV2luQXBpLlNsZWVwKDEpXHBhcg0KXHBhcg0KTVNE
TiBzYXlzOlxwYXINClxwYXINClx0YWIgQSB2YWx1ZSBvZiB6ZXJvIGNhdXNlcyB0aGUgdGhyZWFk
IHRvIHJlbGlucXVpc2ggdGhlIHJlbWFpbmRlciBvZiBpdHNccGFyDQp0aW1lIFxwYXINClx0YWIg
c2x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ludC5ccGFyDQo+IFxwYXINCj4gQnkgdGhlIHdheSwg
aXQgaXMgQ3RybC1CcmVhayBccGFyDQo+IG9yIGZvciB0aGUgZ2VybWFucyBTdHJnLVBhdXNlLlxw
YXINCj4gXHBhcg0KPiBccGFyDQo+IC0gSm9zZWZccGFyDQo+IFxwYXINCj4gXHBhcg0KPiAtLS0t
XHBhcg0KPiBUbyB1bnN1YnNjcmliZSwgc2VuZCBhIG1lc3NhZ2Ugd2l0aCBib2R5ICJTSUdOT0ZG
IEJMQUNLQk9YIiBccGFyDQo+IHRvIExJU1RTRVJWQExJU1RTLk9CRVJPTi5DSFxwYXINCj4gXHBh
cg0KXHBhcg0KXHBhcg0KLS0tLVxwYXINClRvIHVuc3Vic2NyaWJlLCBzZW5kIGEgbWVzc2FnZSB3
aXRoIGJvZHkgIlNJR05PRkYgQkxBQ0tCT1giIHRvIExJU1RTRVJWQExJU1RTfX0AYnkNCiAgICAg
ICAgICA
----boundary-LibPST-iamunique-2020660867_-_---
Received on Tue Dec 08 2009 - 09:44:43 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:30:39 UTC