problem with settimer

Hi
i'm using Settimer in a service. I've called Set timer as

UINT nid = ::SetTimer(NULL, 0,100,(TIMERPROC) MyTimerProc);

where TimerProc is defined as

void CALLBACK MyTimerProc(
   HWND hWnd,      // handle of CWnd that called SetTimer
   UINT nMsg,      // WM_TIMER
   UINT nIDEvent,  // timer identification
   DWORD dwTime    // system time
)
{

    switch(nMsg)
    {
        case WM_TIMER:
        break;
    }
}

I dont know why but i dont get the WM_TIMER event in the callback
function..i mean the function TimerProc is never called even after the time
specified in SetTimer() function..Is the problem with my CallBack function
or what. coz it seems to be working well in other applications..that are not
services.

Thanx and regards

Usman Jamil


0
usman (72)
7/16/2003 1:49:38 PM
vc.mfc 33608 articles. 0 followers. Follow

5 Replies
1511 Views

Similar Articles

[PageSpeed] 24

First: the nMsg parameter is useless, and there is never a reason to ever look at it. It
will ALWAYS be WM_TIMER. The HWND is meaningless, it will always be NULL. The nIDEvent is
rarely useful, since it is rare to have two different timers calling the same timer proc
(if you need two timers, use two timer procs). Only the dwTime has a slight possibility of
being useful.

You will only get timer callbacks if your message pump is active, so if you are off doing
some long computation, no timer events will be seen.
						joe

On Wed, 16 Jul 2003 18:49:38 +0500, "Usman Jamil" <usman@advcomm.net> wrote:

>Hi
>i'm using Settimer in a service. I've called Set timer as
>
>UINT nid = ::SetTimer(NULL, 0,100,(TIMERPROC) MyTimerProc);
>
>where TimerProc is defined as
>
>void CALLBACK MyTimerProc(
>   HWND hWnd,      // handle of CWnd that called SetTimer
>   UINT nMsg,      // WM_TIMER
>   UINT nIDEvent,  // timer identification
>   DWORD dwTime    // system time
>)
>{
>
>    switch(nMsg)
>    {
>        case WM_TIMER:
>        break;
>    }
>}
>
>I dont know why but i dont get the WM_TIMER event in the callback
>function..i mean the function TimerProc is never called even after the time
>specified in SetTimer() function..Is the problem with my CallBack function
>or what. coz it seems to be working well in other applications..that are not
>services.
>
>Thanx and regards
>
>Usman Jamil
>

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
7/16/2003 4:02:03 PM
Why don't you use plain call, like this:
SetTimer(    hwnd,    // handle to main window
                   IDT_TIMER,    // timer identifier
                   n,    // n-second interval
                    (TIMERPROC) NULL);    // no timer callback

and handle WM_TIMER notification? Is there any special reason for you to
define your own timer procedure? If I'm wrong, correct me please.
Regards,
Peter




"Usman Jamil" <usman@advcomm.net> wrote in message
news:uQPRwD6SDHA.2084@TK2MSFTNGP11.phx.gbl...
> Hi
> i'm using Settimer in a service. I've called Set timer as
>
> UINT nid = ::SetTimer(NULL, 0,100,(TIMERPROC) MyTimerProc);
>
> where TimerProc is defined as
>
> void CALLBACK MyTimerProc(
>    HWND hWnd,      // handle of CWnd that called SetTimer
>    UINT nMsg,      // WM_TIMER
>    UINT nIDEvent,  // timer identification
>    DWORD dwTime    // system time
> )
> {
>
>     switch(nMsg)
>     {
>         case WM_TIMER:
>         break;
>     }
> }
>
> I dont know why but i dont get the WM_TIMER event in the callback
> function..i mean the function TimerProc is never called even after the
time
> specified in SetTimer() function..Is the problem with my CallBack function
> or what. coz it seems to be working well in other applications..that are
not
> services.
>
> Thanx and regards
>
> Usman Jamil
>
>



0
programer (27)
7/16/2003 4:15:16 PM
On Wed, 16 Jul 2003 18:49:38 +0500, Usman Jamil wrote:

>I dont know why but i dont get the WM_TIMER event in the callback
>function..i mean the function TimerProc is never called even after the time
>specified in SetTimer() function..Is the problem with my CallBack function
>or what. coz it seems to be working well in other applications..that are not
>services.

If you don't have a message pump (which seems likely in a service),
then your callback won't be called. The "callback" for a timer is
actually called from within message processing in your thread, not by
Windows itself.

You might be better off looking at multimedia timers - see the docs
for timeSetEvent. These support "true" callbacks.

-- 
Bob Moore [WinSDK MVP]
http://www.mooremvp.freeserve.co.uk/
(this is a non-commercial site and does not accept advertising)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Do not reply via email unless specifically requested to do so.
Unsolicited email is NOT welcome and will go unanswered.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0
bobm (116)
7/16/2003 10:08:55 PM
Hi
Thanx for the tip. I used timeSetEvent for it and its working now..but there
is another problem now..The scenario is that the service opens multiple
threads and i have to invoke a seperate timer for each thread..now after
some timer perhaps when many threads have been opened and i try to stop the
service it wont stop..rather hang..can u please tell me if there is some
problem in using multiple mutimedia timers..or is there any check i must
make using mutimedia timer to avoid such situations..

thanx and regards

Usman Jamil
"Bob Moore" <bobm@mvps.org> wrote in message
news:n1jbhv8sabc2hongt19d111jefv4icsuas@4ax.com...
> On Wed, 16 Jul 2003 18:49:38 +0500, Usman Jamil wrote:
>
> >I dont know why but i dont get the WM_TIMER event in the callback
> >function..i mean the function TimerProc is never called even after the
time
> >specified in SetTimer() function..Is the problem with my CallBack
function
> >or what. coz it seems to be working well in other applications..that are
not
> >services.
>
> If you don't have a message pump (which seems likely in a service),
> then your callback won't be called. The "callback" for a timer is
> actually called from within message processing in your thread, not by
> Windows itself.
>
> You might be better off looking at multimedia timers - see the docs
> for timeSetEvent. These support "true" callbacks.
>
> --
> Bob Moore [WinSDK MVP]
> http://www.mooremvp.freeserve.co.uk/
> (this is a non-commercial site and does not accept advertising)
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Do not reply via email unless specifically requested to do so.
> Unsolicited email is NOT welcome and will go unanswered.
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


0
usman (72)
7/18/2003 6:15:35 AM
On Fri, 18 Jul 2003 11:15:35 +0500, "Usman Jamil" <usman@advcomm.net>
wrote:

>can u please tell me if there is some
>problem in using multiple mutimedia timers..or is there any check i must
>make using mutimedia timer to avoid such situations..

I am not aware of any such problem relating to multimedia timers.
Provided that your threads call timeKillEvent before their run
function exits there shouldn't be any issue. Possibly the problem lies
in your threading architecture - was there a problem before you
started using multimedia timers, or did you never get as far as
testing shutdown ?

0
bobm (116)
7/18/2003 12:03:08 PM
Reply:

Similar Artilces:

outlook 2002 problem with reply/forward message
HI all, I'm using OUtlook 2002 with Exchange 5.0. I recently changed my desktop from Win 95 to XP Pro with Office XP Standard. Now I cant reply or forward mails..they stay in the outbox and are not sent. I can only send mail as a new mail. Any help is appreciated.. :S ...

Copy and Paste Problem
Using Publisher 2003. I am trying to copy and paste an Adobe page into a newsletter I am putting together. When I use either the "paste or Special paste" functions the file transfers to the designated page, however, when I try to save the newsletter file I get a blank balloon from the assistant. The only thing that shows in the balloon is an "OK", clicking on the box terminates the program and the just inserted page is not saved. Any ideas on how to work this problem, I really need that Adobe page, tried converting it to a word file, however the formatting and type ...

A strange problem
Hi there, I am compile the program on a english machine, the program can run normally, then I try to run the machine on a chinese machine, but it crashed. I try to debug the program on the chinese machine, such as it crashed at m_CurDateTime = COleDateTime::GetCurrentTime, after press F11, I found in fact it stepped into another function, and the class is not COleDateTime. Program can run on chinese machine normally but crashed on english machine if compile the program on chinese machine. How to solve this type problem? Many thanks for your help. Jack Try look the function HRESULT IDa...

Problem with OWA #4
Hello I have outlook web access setup so users don't need to enter the domain name, just the user name is needed. .... until today. Nothing has changed on the server, on the exchange virtual directory, directory security tab both "integrated windows authentication" and "basic authentication" are checked, with the default domain name being entered. It was working fine up until today, i've tried restarting IIS and restarting the server but it's still requiring the domain name to access webmail. Any ideas what could have gone wrong? Thanks Richard ...

Newsgroup Problems
Hi I use WLM for my two e-mail accounts no problems in or out. I have tried to use "usenet "and entered the account details and message says WLM can't connect to internet may be fire wall or anti virus,checked win fire wall gives it access, I used to have access, but have recently up dated to Win7 so had to reload WLM. Any ideas Please You're getting this from Microsoft Communities if you try to subscribe to a newsgroup? (Newsgroups icon at bottom left of WLMail, right click Microsoft Communities, select "Newsgroups", find your required group, "...

Problem displaying modal dialog box from a dynamically linked regular dll
hi All, i try to call an exported dll function which should create a modal dialog box from an *.exe file. the dll is a regular dynamically linked mfc based dll. my exported function looks like this void CreateDlg() { AFX_MANAGE_STATE(AfxGetStaticModuleState()); CDlg dlg(AfxGetMainWnd()); dlg.DoModal(); } the problem is, that i can see the dialog but it is stuck and the main Dialog window doesn't reponse either. so i have to kill the application. does the code lack of some function overloading ? or message processing ? thanks for any response. I just build a sample and I am not ab...

user acct problem
I have the built in admin acct (which I never use) and the built in guest acct (which I also never use) and the All Users acct and my original acct Owner.RB. All 4 of these accts have been on my laptop since install. I tried creating a new acct awhile back with limited privileges and it froze which later I read that this was probably due to my broadcom wireless driver which was said to not function in an acct that was not admin privileges. So I gave up on that and deleted the new acct. Now some time later I decide to create another new acct but this time make it a admin privilege. H...

Excel Send To function problem
Hi!; I have one question regarding Excel send to function. When I want to send excel information through from email and click the send to menu that build in the excel, the default email editor is MS outlook. In case of I don't want MS outlook as default email editor and I want choose other email editor like Outlook express to do the job. How do I change the setting? Thanks & Regards Control Panel>Internet Options>Programs>Email. Pick OE from the drop-down list. Close Excel and re-start. Note: Outlook and Outlook Express are email clients, not editors. Gord Dibben ...

I need a solution to this problem. How do i fix this ?
MSPUB caused an invalid page fault in module MSPUB.EXE at 017f:0052eda5. Registers: EAX=00022755 CS=017f EIP=0052eda5 EFLGS=00010202 EBX=008df1dc SS=0187 ESP=008df0ac EBP=0000011e ECX=00000015 DS=0187 ESI=006d5f66 FS=5227 EDX=012c02cd ES=0187 EDI=008df0c0 GS=5216 Bytes at CS:EIP: f3 a5 66 a5 5f 5e c2 08 00 90 90 8b 4c 24 04 83 Stack dump: 00000020 0000002f 0052edc2 00001a41 008df0c0 00a2d180 00005168 004f1eb9 008df1dc 006c9624 00000008 008df130 00000002 0000011e 00000008 006ccbac What version Publisher? What are you doing when this error appears? Upgrade your drivers, more than likely it...

Outlook 2000's map display problem
Back in September I installed the latest (at that time) upgrade to Office 2000. It broke Outlook 2000's ability to display a map of a contact's location. Here is the fix they gave to me and it is working now: Use regedit and navigate to the following location: HKEY_CURRENT_USER\Software\Microsoft\Office\9.0\Outlook\Options\General and add the following string mapscripturl then modify the string and put in the following value: http://www.expediamaps.com/default.asp?street=<0s>&city=<1s>&state=<2s>&zip=<3s> Exit Regedit. Henry Winokur To u...

Smarthost relaying problem
We are trying to set up a Smarthost to have all outbound Internet email from our exchange server relayed via another Exchange Server at our parent company. This is necessary because of a reverse lookup issue that is preventing us from sending to AOL and related domains when we send directly from our server (long story). So, I set up their front end server as the Smarthost and it does resolve the issue and most mail goes out just fine. However, if you send messages to two or more addresses in the same domain (e.g. I send test message to 2 hotmail.com addresses that I have), the message...

Need help with a relaying problem
I am having a very obscure relaying problem and I am looking for help. I will do my best to layout the scenario. Their current setup is a Windows Server 2003 AD with Exchange Server 2003 there is only one administrative group and there are SMTP connectors for primary and secondary connections to the internet. On these connectors all mail is rejected to the internet unless you belong to a distribution list called "Internet Users". I have 3 SMTP domain names being utilized in the Exchange Server environment. All of these scenarios below are users that are part of the "Inte...

PDf problems
A couple of weeks ago, when trying to save a file to pdf in Publisher 2007, all the graphics had black around them. Worked fine before that. And it doesn't matter if the graphic/clip art is jpg or png or tiff - same result. I have run all the security/virus scans and Windows updates, deleted the entire Office Suite and reinstalled, but nothing seems to help. So, I have to put the documents on a memory stick and take to my home computer, convert to pdf, then put back on the memory stick to bring in to the office. HELP! What PDF converter are you using? Can you print the docume...

Distribution security problem
I have an issue where a single email account cannot send email to a distribution list. Other users are able to send to it just fine. I have confirmed the account has permission to the group, confirmed its not locked out, etc. Nothing seems to work. Any direction on this would be most appreciated. what happens when this account tries? any error message? -- Susan Conkey [MVP] "Jerry Cutshaw" <JerryCutshaw@discussions.microsoft.com> wrote in message news:934C752A-73FD-4676-82FB-FBAE8A482B2A@microsoft.com... > I have an issue where a single email account cannot sen...

Problem with MS Outlook 2003 and spelling
My MS Outlook 2003 don't perform spelling check, throws an error "error occurred while checkin spelling". The language is set to Lithuanian. "Micorosft Office 2003 Lithuania user interface pack" is installed. MS Word check spelling without any errors. If Use "Microsoft Office Word 2003 to edit e-mail messages" is checked in "Mail Format" tab and Outlook starts Word interface to compose an email, spell checker works fine, but I don't wanna use a Word as email composer. There are installed and other user interface packs as Norway etc. And with this...

Problem with refresh after search
We are using Outlook 2003 SP3 against Exchange 2000. Users are performing a search on their inbox and then attempting to move items that meet the criteria to a personal folders file. The move takes place but the search result does not reflect that the messages were moved and the user does not get an indication that the move was successful. The search results used to refresh pre SP3. Has anyone else experienced this and is a hot fix available? Thanks ...

Excel 2007 Crashing Problem #3
My company has been riddled with Excel 2007 crashing since we started migrating to the 07 suite. Two users who prominently use Excel for their job tasks have seen many issues mainly when converting .xls documents to .xlsx. The common theme i have seen here has been file size and weather or not the file contains links. Both users also work heavily with graphs. My question is, has there been reported problems with converting large excel files to the new format? Or has there been a graphing problem? ...

Re: Problem with Xpath query !!!
"Nakah" <nakahspam@free.fr> wrote in message news:... > Thanks, I've just tried it but it doesn't work :'( > > > "Derek Harmon" <loresayer@msn.com> wrote in message > news:uqmsyB%23HEHA.2300@tk2msftngp13.phx.gbl... > > "Nakah" <nakahspam@free.fr> wrote in message > news:OcqK488HEHA.1448@TK2MSFTNGP10.phx.gbl... > > > I have some troubles with Xpath when I'm using it with a XmlDocument > containing two namespaces. > > > Here is the XmlDocument : > > > > > > <grammar ...

Staring Excel Problem
Hi All! I have installed windows XP followed by SP2. So I installed Office 2003. Every time I start excel it shows me a message saying "Instalando : recurso do Microsoft Excel" (In English is "Installing : Component (or resource) of Microsoft Excel" I think). It happens every time I start excel and take a minute and it is annoying me very much. Any help is welcome. Thanks in advance Everton Brasil Everton Have you gone to Control Panel>Add/Remove and selected Office 2003 and "Change"? Perhaps Excel is not set up to "run all from my computer&quo...

Problem sending BCC's
I'm a photographer and I have lead emails that I can cut and paste from an excel program and just paste it into BCC so I can mass mail brides, and it loads them all with no problems. But now that I've switched to Windows 7 mail I can't do it. It acts weird and won't load the email addresses in BCC. The names are there when I paste them in, but it won't send. It says the name isn't in the contact. How can I get around this? thanks! Assuming 'lead' means potential customers vs. the period table - How many addresses are you mass mailing ? Windows 7...

Problem with Outlook 2002 #2
Hello, I have several personal folders (PST files) witch I would like to make for each one a name. But when I customized a name for each one and I make an auto archive the customized names disappeared and replaced by Personal folder. So any help will be appreciated thanks in advance. Rob Hey Rob, please r-click on ur personal Folder. Properties, than on the first rider more and after that you could change your name there. If you dont understand me please send me an email, i could send you screenshots. >-----Original Message----- >Hello, >I have several personal folders (PST ...

Switching problem between dialog and view
Hello, I have a CFormView.I need a menu for my chile window seperately. So on my view I attached a dialog which has a menu. When I click on view, the dialog appears to be grayed, but when clicked on dialog the menu appears to be enabled. The same is the case with view, it appears to be grayed when clicked on dialog(i.e menu on dialog). Is there any way to make the dialog appear as enabled always irrespective of the focus on it? can anyone please help me to solve this? Thanks Madhavi ...

Cell Spacing Problem
Hi All, I'm having a problem with a file that's used around our office fo record keeping. On everyone else's computer (running Win2K and Offic 2000), the file fits on one page and looks fine when printed. O another computer (running WinXP and Office 2000) it also looks/print fine. This brings me to my computer (IBM Thinkpad T41) running (WinXP). Originally I installed Office 2003 and when I opened the file tha everyone else used, it no longer fit on 1 page. I double checked th margins and column widths and they were all the same. But visuall speaking, it was obvious that my c...

Importing text problems
Hello, I am trying to import a list into Excel, and having trouble getting past the import wizard. The data seems to be separated by various symbols, and I cannot seem to separate my data so it imports to a useable form. Wondering if I could send a sample of this data (text file) to someone proficient in Excel to try and import? Any help would be greatly appreciated. Thanks very much. If the number of delimiters is limited (pretty small???), then maybe just open the text file in your favorite editor and do some Edit|Replaces to make all the delimiters the same. It might be easier to just...

Selectnodes
Hi, Given this: http://rss.asdf.dk/theothermusic.rss how do you use selectnodes/Xpath to return all title-items (//title is not working). I think it a problem with namespace but i can't solve the problem. Thanks, Mads MacDk wrote: > http://rss.asdf.dk/theothermusic.rss > > how do you use selectnodes/Xpath to return all title-items (//title is > not working). I think it a problem with namespace but i can't solve > the problem. //rss:title And don't forget to bind rss prefix to appropriate namespace in XmlNamespaceManager. If this is still not insightful for...