By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,201 Members | 937 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,201 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: 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.