473,770 Members | 6,506 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Windows Service - need Windows.Forms.A pplication.DoEv ent() equiv

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

The service makes a web request using the
mshtml.HTMLDocu ment.CreateDocu mentFromURL() function

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

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

thanks
Jul 21 '05 #1
3 9430
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.HTMLDocu ment.CreateDocu mentFromURL() function

Because this is not using Windows.Forms, I can't use the
Application.DoE vents() 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 CreateDocumentF romURL from a seperate
thread and spin it until Document.readyS tate != "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.re adyState != "complete")

{

// Application.DoE vents();

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

thanks
"Elp" <ro********@REM OVEME.hotmail.c om> 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.HTMLDocu ment.CreateDocu mentFromURL() function

Because this is not using Windows.Forms, I can't use the
Application.DoE vents() 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 CreateDocumentF romURL from a seperate
thread and spin it until Document.readyS tate != "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 New Member
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.GetDa ta(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.HTMLDocu ment.CreateDocu mentFromURL() function
>
> Because this is not using Windows.Forms, I can't use the
> Application.DoE vents() 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 CreateDocumentF romURL from a seperate
> thread and spin it until Document.readyS tate != "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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2698
by: pberna | last post by:
Dear all, I built a Web Form application to start and stop a Windows Service remotely. I successful tested the application on Windows 2000 server + IIS. I must include the ASPNET user to the Administration group (on server side) to have the necessary authorization to start a Windows Service (I don't understand why "Power User" rights are not enough to do the same thing) Although I'm able to start a service using windows 2000 server...
4
17005
by: Jim | last post by:
I am writing a Windows Service in VB.Net, and right upfront I need to pass the path to my config.xml file to the constructor of the class which reads it. In the old days, App.Path & "\config.xml" would have done nicely. I have tried using Reflection.Assembly.GetExecutingAssembly.Location but this is horrible! I can't use the easy Application.Path property because it is a service not a Forms application. Is there a simple way to do this,...
4
5611
by: Blaxer | last post by:
I have read approximately 30 articles now on various methods to make your vb.net application automatically update itself and I can't see how they apply to a vb.net windows services projects. The goal of the project is to write a windows service in vb.net that runs on many workstations that can automatically update itself from a central web server or share (either or doesn’t matter). I do not want the service to re-install itself each time...
2
420
by: James Dixon | last post by:
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"?
2
6760
by: Ludovic DE FREITAS | last post by:
Hello, I am making a prototype system with a Pocket PC that must connect to a Server Application. Unfortunately, the server cannot be a Web Server, but a simple Windows Forms Application. Here is my question: The only way to easily communicate for a Pocket PC is the Web Service. Is it possible to host a web service in a Windows Forms Application ?
2
6899
by: deko | last post by:
When to use a privileged user thread rather than a windows service? That's the question raised in a previous post . It was suggested that if the service needs to interact with a WinForms app (which is the UI used to adjust the actions taken by, and the schedule of the service), then a privileged user thread should be used in the UI - no service required. But... "A windows service enables the creation of long-running executable
4
4182
by: tshad | last post by:
What would be a good way to check programmatically whether a service was running? We have a service that dies periodically and I need to check to see if this service is running. I know how to check to see if the status is in stopped or running mode. But that doesn't tell me if it is actually running. I need to know this so that if it happens I can programmatically start the same service on another machine.
2
508
by: shapper | last post by:
Hello, I usually develop Asp.Net 2.0 (With VB.NET or C#) web sites with SQL 2005 databases. A few of my web sites use online CMS with AJAX. I need to create a Windows Vista compatible application that includes the features I usually have in my CMS: 1. Send a retrieve content from the web site SQL 2005 database.
15
7088
by: =?Utf-8?B?TVNU?= | last post by:
To demonstrate my problem, I have a very simple VB Windows application. It has a text box that is used to display a counter, a button to reset the counter, and a timer that increments the counter every second. I remote desktop to the computer hosting this application and run the application. It starts up and displays the counter incrementing every second. If I disconnect the network cable between the two computers for 10 seconds and...
0
9591
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10228
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10002
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7415
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6676
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5312
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5449
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3575
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.