469,626 Members | 1,369 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,626 developers. It's quick & easy.

Windows Service - need Windows.Forms.Application.DoEvent() equiv

I have created a windows service in C#, .net framework 1.1

The service makes a web request using the
mshtml.HTMLDocument.CreateDocumentFromURL() function

Because this is not using Windows.Forms, I can't use the
Application.DoEvents() function while the request is completing. Is there
an equivilent function (call the CreateDocumentFromURL from a seperate
thread and spin it until Document.readyState != "complete"?

Or just use Windows Forms namespace to access the Application object?

thanks
Jul 21 '05 #1
3 9082
Elp
On Tue, 15 Feb 2005 08:22:40 -0500, James Dixon wrote:
I have created a windows service in C#, .net framework 1.1

The service makes a web request using the
mshtml.HTMLDocument.CreateDocumentFromURL() function

Because this is not using Windows.Forms, I can't use the
Application.DoEvents() function while the request is completing.
Why do you need to call DoEvents from a Windows Service? All that DoEvent
does is to tell your application's Windows to process events from the
message loop (those events can be eg Repaint Window or Move Window). In a
windows service you have no user interface, no windows and no message loop
so DoEvents won't do anything.
Is there
an equivilent function (call the CreateDocumentFromURL from a seperate
thread and spin it until Document.readyState != "complete"?


You could maybe precise a bit more what you are trying to achieve. I don't
see the point of launching a new thread and then simply loop until this
thread has finished its job. Use threads only if you need to do several
things in parallel.
Jul 21 '05 #2
I didn't know if the HTMLDocument needs some kind of external notification
to finish
so I'll just do this:
while (objDocument.readyState != "complete")

{

// Application.DoEvents();

}
and when it is done looping, I can start parsing the doc
I'll let you know if it works

thanks
"Elp" <ro********@REMOVEME.hotmail.com> wrote in message
news:1e******************************@40tude.net.. .
On Tue, 15 Feb 2005 08:22:40 -0500, James Dixon wrote:
I have created a windows service in C#, .net framework 1.1

The service makes a web request using the
mshtml.HTMLDocument.CreateDocumentFromURL() function

Because this is not using Windows.Forms, I can't use the
Application.DoEvents() function while the request is completing.


Why do you need to call DoEvents from a Windows Service? All that DoEvent
does is to tell your application's Windows to process events from the
message loop (those events can be eg Repaint Window or Move Window). In a
windows service you have no user interface, no windows and no message loop
so DoEvents won't do anything.
Is there
an equivilent function (call the CreateDocumentFromURL from a seperate
thread and spin it until Document.readyState != "complete"?


You could maybe precise a bit more what you are trying to achieve. I don't
see the point of launching a new thread and then simply loop until this
thread has finished its job. Use threads only if you need to do several
things in parallel.

Jul 21 '05 #3
jbeyer
1
Elp,

I came across your post through a Google search. I am trying to create a Windows Service that generates keystrokes, namely, a PrtScr keystroke.
I came across the following code to do so:
'The second parameter (bScan) determines what
'to copy... passing 0& copies the screen or
'passing 1& copies the active form.
keybd_event vbKeySnapshot, 0&, 0&, 0&

'pause to let Windows update the clipboard
DoEvents

'retrieve the clipboard bitmap to the control
Image1.Picture = Clipboard.GetData(vbCFBitmap)

The DoEvents command is not available in my service, and without it, the keystroke doesn't seem to be absorbed by Windows.
Do you have any suggestions? Pardon my naivety, I'm a complete newbie to VB.

Cheers,
Jon



On Tue, 15 Feb 2005 08:22:40 -0500, James Dixon wrote:
[color=blue]
> I have created a windows service in C#, .net framework 1.1
>
> The service makes a web request using the
> mshtml.HTMLDocument.CreateDocumentFromURL() function
>
> Because this is not using Windows.Forms, I can't use the
> Application.DoEvents() function while the request is completing.[/color]

Why do you need to call DoEvents from a Windows Service? All that DoEvent
does is to tell your application's Windows to process events from the
message loop (those events can be eg Repaint Window or Move Window). In a
windows service you have no user interface, no windows and no message loop
so DoEvents won't do anything.
[color=blue]
> Is there
> an equivilent function (call the CreateDocumentFromURL from a seperate
> thread and spin it until Document.readyState != "complete"?[/color]

You could maybe precise a bit more what you are trying to achieve. I don't
see the point of launching a new thread and then simply loop until this
thread has finished its job. Use threads only if you need to do several
things in parallel.
Apr 27 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Ludovic DE FREITAS | last post: by
4 posts views Thread by tshad | last post: by
2 posts views Thread by shapper | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.