PC Review


Reply
Thread Tools Rate Thread

DoEvents in Windows Service

 
 
Elmo Watson
Guest
Posts: n/a
 
      19th Dec 2007
I have a windows service that, technically works most of the time, but I
think I'm running into a situation that is caused due to actions being
started before the last action is completed.

In a Windows Forms application, I'd do this to overcome this:
System.Windows.Forms.Application.DoEvents

However, in my designer for the Windows Service (using the FileWatcher),
this is not available

So, how can I accomplish 'DoEvents' in a Windows Service?


 
Reply With Quote
 
 
 
 
coolCoder
Guest
Posts: n/a
 
      20th Dec 2007
On Dec 19, 10:37 pm, "Elmo Watson" <s...@here.com> wrote:
> I have a windows service that, technically works most of the time, but I
> think I'm running into a situation that is caused due to actions being
> started before the last action is completed.
>
> In a Windows Forms application, I'd do this to overcome this:
> System.Windows.Forms.Application.DoEvents
>
> However, in my designer for the Windows Service (using the FileWatcher),
> this is not available
>
> So, how can I accomplish 'DoEvents' in a Windows Service?


Are you using multiple threads ? If yes, then synchronize them, to
avoid these kind of situations.
 
Reply With Quote
 
Rob
Guest
Posts: n/a
 
      20th Dec 2007
"Elmo Watson" wrote:
> I'm running into a situation that is caused due to actions being
> started before the last action is completed.

The service needs to have some sort of synchronization code to ensure the
events run in order. If action B depends on A having finished, then B needs
to check that A is done before running. The details will be specific to your
app.

> In a Windows Forms application, I'd do this to overcome this:
> System.Windows.Forms.Application.DoEvents

This is almost always a bad idea. DoEvents starts a second message pump and
can cause reentrancy problems such as what you describe. It should only be
used very deliberately and not as a generic "fix me" API.

> So, how can I accomplish 'DoEvents' in a Windows Service?

DoEvents runs the message pump. Since services do not generally have
windows, they don't generally pump messages.

--Rob
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Application.DoEvents() Equivalent in a Windows Service. Tino Donderwinkel Microsoft C# .NET 3 21st Mar 2008 03:52 PM
Windows The Windows Media Connect Service service failed to start due to the following error: Donald Bock Windows XP Help 1 5th Oct 2007 01:28 AM
Windows Service and application.DoEvents() Wolfgang Kutschera Microsoft VB .NET 3 5th Apr 2005 04:01 PM
2nd form's DoEvents pauses 1st form's DoEvents Albert Microsoft Access Form Coding 3 23rd Feb 2004 11:49 PM
Application.DoEvents in a service Peter B Rasmussen Microsoft VB .NET 3 19th Nov 2003 01:28 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:38 AM.