G
Guest
Hello,
I am considering using Serviced Components to process jobs (file loading
into a Document Management System) asssynchronously.
I have started to write a Serviced Component to handle the job queue using
MS Message Queues. This component reads the queue and calls a method using
events and delegates:
using (JobManager jobQueue = new JobManager) {
// submit job (testing purpose)
for ( int i = 0; i< 4; i++ ) {
jobQueue.SubMit(« task »);
}
// register the delegate
jobQueue.MessageReceived += new MessageReceiveEvent(ProcessMessage);
// start job processing
jobQueue.Start();
Console.ReadLine();
}
When I run the application, the Start method raises an exception (before
reading a message from the queue, I check if there is at least on registered
event, if not I don't want to read the queue and loose messages).
To figure out what's wrong, I set a break point into the JobManager
constructor (as reminder, it's a Serviced Component): the constructor was
called several times during the using statement. So, the JobManager lost the
delegate registered by the calling application, since new objects are created
before each method calls (I guess).
I guess Serviced Components are designed to run method independtly: each
method runs as a 'service'.
So my question is: Using Serviced Components, don't we loose the benefits of
object programming ?
Jean-Pierre.
I am considering using Serviced Components to process jobs (file loading
into a Document Management System) asssynchronously.
I have started to write a Serviced Component to handle the job queue using
MS Message Queues. This component reads the queue and calls a method using
events and delegates:
using (JobManager jobQueue = new JobManager) {
// submit job (testing purpose)
for ( int i = 0; i< 4; i++ ) {
jobQueue.SubMit(« task »);
}
// register the delegate
jobQueue.MessageReceived += new MessageReceiveEvent(ProcessMessage);
// start job processing
jobQueue.Start();
Console.ReadLine();
}
When I run the application, the Start method raises an exception (before
reading a message from the queue, I check if there is at least on registered
event, if not I don't want to read the queue and loose messages).
To figure out what's wrong, I set a break point into the JobManager
constructor (as reminder, it's a Serviced Component): the constructor was
called several times during the using statement. So, the JobManager lost the
delegate registered by the calling application, since new objects are created
before each method calls (I guess).
I guess Serviced Components are designed to run method independtly: each
method runs as a 'service'.
So my question is: Using Serviced Components, don't we loose the benefits of
object programming ?
Jean-Pierre.