Hi All, I have written a win service MSMQListener. On the OnStart method I
call a queue worker class which basically goes and invokes the delegate with
the following signature
OnStart()
{
QWorker q=new QWorker();
q.Run();
}
class QWorker{
void Run()
{
this.msmq=new MessageQueue(path);
this.msmq.ReceiveCompleted += new
System.Messaging.ReceiveCompletedEventHandler(this .msmq_ReceiveCompleted);
}
private void msmq_ReceiveCompleted(object sender, ReceiveCompletedEventArgs
e)
{
// do something
}
} // end of QWorker
I wanted to know what should I do on the OnStop method of the Service
Controller, because if I call GC.Collect on the stop method my service
crashes.
BTW If Don't do anything on the OnStop method everything is fine!!!!!
OnStop()
{
GC.Collect(); // Crashes
}
TIA
--
========
Regards
Vai
======== 5 1428
Vai,
Why are you calling GC.Collect in the first place? You should let the
runtime do this on its own unless you have a specific reason.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Vai2000" <no****@microsoft.com> wrote in message
news:Ot**************@TK2MSFTNGP12.phx.gbl... Hi All, I have written a win service MSMQListener. On the OnStart method I call a queue worker class which basically goes and invokes the delegate
with the following signature
OnStart() { QWorker q=new QWorker(); q.Run(); }
class QWorker{
void Run() { this.msmq=new MessageQueue(path); this.msmq.ReceiveCompleted += new System.Messaging.ReceiveCompletedEventHandler(this .msmq_ReceiveCompleted); } private void msmq_ReceiveCompleted(object sender,
ReceiveCompletedEventArgs e) {
// do something
} } // end of QWorker
I wanted to know what should I do on the OnStop method of the Service Controller, because if I call GC.Collect on the stop method my service crashes. BTW If Don't do anything on the OnStop method everything is fine!!!!!
OnStop() { GC.Collect(); // Crashes }
TIA
-- ======== Regards Vai ========
To interrupt or stop the service and free resources. So should there be any
other code on the OnStop method?
TIA
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:Oh**************@TK2MSFTNGP12.phx.gbl... Vai,
Why are you calling GC.Collect in the first place? You should let the runtime do this on its own unless you have a specific reason.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Vai2000" <no****@microsoft.com> wrote in message news:Ot**************@TK2MSFTNGP12.phx.gbl... Hi All, I have written a win service MSMQListener. On the OnStart method
I call a queue worker class which basically goes and invokes the delegate with the following signature
OnStart() { QWorker q=new QWorker(); q.Run(); }
class QWorker{
void Run() { this.msmq=new MessageQueue(path); this.msmq.ReceiveCompleted += new
System.Messaging.ReceiveCompletedEventHandler(this .msmq_ReceiveCompleted); } private void msmq_ReceiveCompleted(object sender, ReceiveCompletedEventArgs e) {
// do something
} } // end of QWorker
I wanted to know what should I do on the OnStop method of the Service Controller, because if I call GC.Collect on the stop method my service crashes. BTW If Don't do anything on the OnStop method everything is fine!!!!!
OnStop() { GC.Collect(); // Crashes }
TIA
-- ======== Regards Vai ========
Vai2000,
The whole point of the GC is that you do not have to manage these
things. Unless you have a very specific reason (other than freeing
resources, which isn't really adequate), you should let the GC handle
itself. For what you are doing, I would recommend removing the call to
GC.Collect. The runtime will manage everything appropriately.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Vai2000" <no****@microsoft.com> wrote in message
news:uT****************@TK2MSFTNGP10.phx.gbl... To interrupt or stop the service and free resources. So should there be
any other code on the OnStop method?
TIA
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:Oh**************@TK2MSFTNGP12.phx.gbl... Vai,
Why are you calling GC.Collect in the first place? You should let
the runtime do this on its own unless you have a specific reason.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Vai2000" <no****@microsoft.com> wrote in message news:Ot**************@TK2MSFTNGP12.phx.gbl... Hi All, I have written a win service MSMQListener. On the OnStart
method I call a queue worker class which basically goes and invokes the
delegate with the following signature
OnStart() { QWorker q=new QWorker(); q.Run(); }
class QWorker{
void Run() { this.msmq=new MessageQueue(path); this.msmq.ReceiveCompleted += new System.Messaging.ReceiveCompletedEventHandler(this .msmq_ReceiveCompleted); } private void msmq_ReceiveCompleted(object sender,
ReceiveCompletedEventArgs e) {
// do something
} } // end of QWorker
I wanted to know what should I do on the OnStop method of the Service Controller, because if I call GC.Collect on the stop method my service crashes. BTW If Don't do anything on the OnStop method everything is fine!!!!!
OnStop() { GC.Collect(); // Crashes }
TIA
-- ======== Regards Vai ========
Are you sure everything is fine?
IMO this service doesn't do what you expected, because you did something
fundametaly wrong, that is executing service code in the OnStart method
while it should only initialize the service and return as soon as possible
(at least before the SCM times out (30 sec.)).
Willy.
"Vai2000" <no****@microsoft.com> wrote in message
news:Ot**************@TK2MSFTNGP12.phx.gbl... Hi All, I have written a win service MSMQListener. On the OnStart method I call a queue worker class which basically goes and invokes the delegate
with the following signature
OnStart() { QWorker q=new QWorker(); q.Run(); }
class QWorker{
void Run() { this.msmq=new MessageQueue(path); this.msmq.ReceiveCompleted += new System.Messaging.ReceiveCompletedEventHandler(this .msmq_ReceiveCompleted); } private void msmq_ReceiveCompleted(object sender,
ReceiveCompletedEventArgs e) {
// do something
} } // end of QWorker
I wanted to know what should I do on the OnStop method of the Service Controller, because if I call GC.Collect on the stop method my service crashes. BTW If Don't do anything on the OnStop method everything is fine!!!!!
OnStop() { GC.Collect(); // Crashes }
TIA
-- ======== Regards Vai ========
All I do is Write to file inside the ReceiveComplete Delegate and do
msmq.BeginReceive();
TIA
"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:O8**************@TK2MSFTNGP10.phx.gbl... Are you sure everything is fine? IMO this service doesn't do what you expected, because you did something fundametaly wrong, that is executing service code in the OnStart method while it should only initialize the service and return as soon as possible (at least before the SCM times out (30 sec.)).
Willy.
"Vai2000" <no****@microsoft.com> wrote in message news:Ot**************@TK2MSFTNGP12.phx.gbl... Hi All, I have written a win service MSMQListener. On the OnStart method
I call a queue worker class which basically goes and invokes the delegate with the following signature
OnStart() { QWorker q=new QWorker(); q.Run(); }
class QWorker{
void Run() { this.msmq=new MessageQueue(path); this.msmq.ReceiveCompleted += new
System.Messaging.ReceiveCompletedEventHandler(this .msmq_ReceiveCompleted); } private void msmq_ReceiveCompleted(object sender, ReceiveCompletedEventArgs e) {
// do something
} } // end of QWorker
I wanted to know what should I do on the OnStop method of the Service Controller, because if I call GC.Collect on the stop method my service crashes. BTW If Don't do anything on the OnStop method everything is fine!!!!!
OnStop() { GC.Collect(); // Crashes }
TIA
-- ======== Regards Vai ========
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Hardy Wang |
last post by:
Hi all:
I read an article from
http://www.c-sharpcorner.com/Code/2003/Sept/InstallingWinServiceProgrammatically.asp
about how to install a windows service programmatically.
Based ont the code...
|
by: Mike |
last post by:
I want to create a windows service that will monitor another window service.
what i need for the service to do is, if a service is stopped I need it to
start the service back up
example:
...
|
by: SP |
last post by:
Hi All,
I wrote a windows service which is supposed to stop after specified amount
of time. I am calling OnStop() after specified time. OnStop() methods
executed but I dont see the service...
|
by: Jeremy S. |
last post by:
On my dev machine (XP/Pro with VS.NET 2003) I have been developing a Windows
Service and installing it on the local machine by opening the Visual Studio
Command Prompt and then executing .
Now I...
|
by: letibal |
last post by:
Hello,
I have written a windows service and created an installer for it.
The service runs under the system accounts. When started, it launches a
GUI.
By default, the InteractiveProcess property...
|
by: kkt49 |
last post by:
# vim: et sw=4 ts=8 sts
from wxPython.wx import *
import sys, os, time
import pywintypes
import win32serviceutil
import win32service
import win32event
import win32process
|
by: carson |
last post by:
I have written two windows services:
- service A does some crunching of local data files and uploads them to
a central processing computer via http.
- service B monitors a manifest file on a...
|
by: dmjpro |
last post by:
plz send me a good link which can clearify me how the J2EE framework works
i want the details information .... plz help
thanx
|
by: =?Utf-8?B?cmtibmFpcg==?= |
last post by:
I was executing the steps given in http://suppor.microsoft.com/kb/308359 for
testing a sample web service application. However, the following line gives a
compilation error:
localhost.Service1...
|
by: dm3281 |
last post by:
I'm really starting to hate writing services -- or trying to, anyway.
Why do I need to rename my project to the service name?
Why do I need to set the "ServiceName" property to my service name?...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
| |