Re: Delay inside a worker thread
From: Ian Semmel (isemmel_at_removejunkmailrocketcomp.com.au)
Date: 01/25/05
- Next message: Ata ul Haq: "NT Service crash at RtlEnterCriticalSection"
- Previous message: Dan McCarty: "Re: Keyboard shortcut for "1 of 2" tooltip?"
- In reply to: Tulio: "RE: Delay inside a worker thread"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 26 Jan 2005 07:21:37 +1000
I think that what you have to do is ditch the worker thread and the sleep, and
instead opt for UI threads.
You can have multiple layers of threads with the controlling thread looking
after the timers and logical device state etc.
Create invisible windows and use PostMessage to communicate between the threads
(you should logically be using PostThreadMessage, but because of a fundamental
design flaw in Windows they are useless).
Tulio wrote:
> Hello again
>
> Thanks for the help Andy.
> I'm using Windows 2000 and Windows XP, Visual Studio .NET2003 and C++ with
> MFC (no .NET framework is used).
>
> About the board and API I think that I wasn't very clear in my explanation.
> The problem is not to let tool on/off for some period of time. Is more like
> switch the tool on, wait x seconds then execute next block of C++ code. I
> really would appreciate if the manufacturer had provided a function that will
> wait xx seconds after the port was set, but that is not the case ... This
> board has 4 ports, each one has 7 bits. Setting the bits in a particular port
> turns that I/O line on/off, but the function expetcs to receive a bitmap of
> bits to set. So all bits on that port are set at once.
>
> I'm looking at that link and I think that CreateWaitableTimer can do the
> trick. Since we design that part of code in a more procedural way rather than
> event-drive I think it can be more easily adapted.
>
> Many thaks !
>
> "Andy Mortimer [MS]" wrote:
>
>
>>Hi,
>>Which verson of windows are you using, and which compiler are you
>>developing with?
>>
>>Does the board manufacturer provide callbacks which you can register for
>>i.e. tell me when the status of something is such and such, then you get a
>>hardware interupt which is signalled to your callback function in real
>>time? They may even provide hardware timers which you can program and
>>register for notification.
>>
>>Alternatively, you can use a multimedia timers
>>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/ht
>>m/_win32_about_multimedia_timers.asp
>>
>>To be honest though, it sounds like your hardware and driver set is a
>>little bit lacking. You can turn a tool on, and you can turn it off, so why
>>can't you turn it on for a specific period of time. This should be provided
>>by the device driver, you should simply have to call an API with an On Off
>>flag and a period of time. Alternatively, the driver should inform you when
>>the operation has completed with a callback.
>>
>>Andy Mortimer [MS]
>>Please do not send email directly to this alias. This alias is for
>>newsgroup purposes only
>>
>>This posting is provided "AS IS" with no warranties, and confers no rights.
>>OR if you wish to include a script sample in your post please add "Use of
>>included script samples are subject to the terms specified at
>>http://www.microsoft.com/info/cpyright.htm"
>>
>>
>>
>>
- Next message: Ata ul Haq: "NT Service crash at RtlEnterCriticalSection"
- Previous message: Dan McCarty: "Re: Keyboard shortcut for "1 of 2" tooltip?"
- In reply to: Tulio: "RE: Delay inside a worker thread"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|