473,782 Members | 2,423 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Windows service. "Running" my class

Sorry for such a daft question.
Ive been following some tutorials on creating windows services. Ive not done
them before.
In my original debuggable windows form application, I create my worker
classes. The classes 'run' themselves using several threads and only stop
when the form is closed.
Now I've used these worker classes in the service application. When I try to
run my service manually, I am given a message that the service stopped
itself. I'm not sure if there's a problem with my code yet, but it led me
to wonder if the following code would just lead to my object being created
followed immediately by the function exiting and the service finishing. Is
there anything I need to do to keep driving a service application?

private MMonitor Monitor = null;

protected override void OnStart(string[] args)
{
Monitor = new MMonitor();
}
Nov 17 '05 #1
3 1639
Hi Claire,

From the debugger stand point I think that it will treat your service
application like any other application. When you register the application
as a service it stays memory resident until it receives a service stop event
from the SCM. When in debugger mode there is no SCM to issue the events so
treat it like any other applicaiton. Now speaking for MMonitor, is this a
threaded class that you created, for debugging purposes if you could
implement a "wait" signal so that you can do something like:

Monitor.WaitFor ();

Then your main service thread will idle until the Monitor object is
completed with its task and stay memory resident (not terminated).

Alex

"Claire" <no***@yournell y.com> wrote in message
news:ui******** ******@TK2MSFTN GP10.phx.gbl...
Sorry for such a daft question.
Ive been following some tutorials on creating windows services. Ive not
done them before.
In my original debuggable windows form application, I create my worker
classes. The classes 'run' themselves using several threads and only stop
when the form is closed.
Now I've used these worker classes in the service application. When I try
to run my service manually, I am given a message that the service stopped
itself. I'm not sure if there's a problem with my code yet, but it led me
to wonder if the following code would just lead to my object being created
followed immediately by the function exiting and the service finishing. Is
there anything I need to do to keep driving a service application?

private MMonitor Monitor = null;

protected override void OnStart(string[] args)
{
Monitor = new MMonitor();
}

Nov 17 '05 #2
Hi Claire,

In order to test what is going on add your initialization code on the
OnContinue, so run the service and the pause it, attach your debugger and the
put a breakpoint on OnContinue, Press resume and you can see what is going on.

hope this helps to solve it
salva

"Claire" wrote:
Sorry for such a daft question.
Ive been following some tutorials on creating windows services. Ive not done
them before.
In my original debuggable windows form application, I create my worker
classes. The classes 'run' themselves using several threads and only stop
when the form is closed.
Now I've used these worker classes in the service application. When I try to
run my service manually, I am given a message that the service stopped
itself. I'm not sure if there's a problem with my code yet, but it led me
to wonder if the following code would just lead to my object being created
followed immediately by the function exiting and the service finishing. Is
there anything I need to do to keep driving a service application?

private MMonitor Monitor = null;

protected override void OnStart(string[] args)
{
Monitor = new MMonitor();
}

Nov 17 '05 #3

"Claire" <no***@yournell y.com> wrote in message
news:ui******** ******@TK2MSFTN GP10.phx.gbl...
Sorry for such a daft question.
Ive been following some tutorials on creating windows services. Ive not
done them before.
In my original debuggable windows form application, I create my worker
classes. The classes 'run' themselves using several threads and only stop
when the form is closed.
Now I've used these worker classes in the service application. When I try
to run my service manually, I am given a message that the service stopped
itself. I'm not sure if there's a problem with my code yet, but it led me
to wonder if the following code would just lead to my object being created
followed immediately by the function exiting and the service finishing. Is
there anything I need to do to keep driving a service application?

private MMonitor Monitor = null;

protected override void OnStart(string[] args)
{
Monitor = new MMonitor();
}


OnStart is meant to initialize you service and to start your service task on
another thread. Your service will be flagged as "failed to start in a timely
fashion" if you don't return within 30 seconds after the service start
command.
I'm unclear on what you are doing in your MMonitor constructor, but it looks
like you simply return, as a consequence you return from OnStart without
having created a service thread.

Willy.

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3514
by: John Spiegel | last post by:
Hi all, I think this is a longshot, but is there a technique for programmatically run a webpage? Let's say one of our vendors has a page that we go to daily to pick up some files. Each time, the user clicks a link, that brings up a file dialog prompting for a local name to download to and OK's. This process is repeated for a number of files.
3
1774
by: Amy L. | last post by:
I have a windows service where I would like to launch a script (bat, cmd, vbs, exe, etc) from the service. This script should execute in the background and not require any input from the user (i.e. not interact with the desktop). I have been looking at System.Diagnostics.Process.Start() to launch this script. Here are my questions based on this. 1.) Is this the right namespace to be using?
2
307
by: H Branyan | last post by:
In the Application_OnStart event in global.asax, my code calls an AlertService which creates a System.Timers.Timer() object. So this service doesn't actually run in conjunction with a specific aspx page, apparently. When the timer's Elapsed event handler fires, it calls some other classes I have written. These classes output some Trace statements that you can view if an aspx page calls them, but I can't seem to figure out where the Trace...
2
1895
by: Mike Kingscott | last post by:
Hi all, Ok, I'm running Windows 2000, service pack 4. I have .Net framework installed, version 1.1.4322, I'm running IIS 5.0. When I try to open a solution that was opening just dandy last week, I get the error "Visual Studio .NET has detected that the specified Web server is not running ASP.NET version 1.1" I HAVE ALREADY TRIED RUNNING aspnet_regiis -i (SEVERAL TIMES) WITH *NO* LUCK
4
4184
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.
4
1839
by: Mr BigSmoke | last post by:
Hi All, I'm developing a website to handle some code/application version control on a intranet. I'm using cherrypy and pysvn. Everything runs quite good but i want the user to be able to checkout some projects from the server. The user(on the client side) selects a folder in his machine (i.e.: C:\Project1) and the server should checkout (download/copy) all the project selected to the client machine. But what happens is that the webserver...
5
2835
by: =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?= | last post by:
Hi; How are we supposed to handle this. It appears that this must be run on a system for an ASP.NET app to run. On WinXP we are finding that the user ASPNET does not exist until this is run. However, running this impacts all existing ASP.NET apps and sets the default ..NET for all new ones. So if we run this we can screw up all the ASP.NET apps already on a system.
2
1303
by: Javier1958 | last post by:
Hi all I have a problem running Visual Basic 2005 (.NET) programs in other computers different of that where I have Visual Studio installed. I know I have to install the .NET framework in the other computers and so I did. I don't have problems with simple programs. They run nicely. The problem is with programs that use Excel files. In fact with just adding Imports Microsoft.Office.Interop.Excel to the program hampers it of running in...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10313
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...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9946
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6735
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
5378
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...
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2875
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.