C # Use delegation in Windows Service Development

Source: Internet
Author: User

 

Code Private Thread workerThread = null;
Private Subscriber sub;

Public DataReceiveService ()
{
InitializeComponent ();
CanShutdown = true;
CanStop = true;
Sub = new Subscriber ();
}

Protected override void OnStart (string [] args)
{
EventLog. WriteEntry ("Start Server:" + DateTime. Now. ToString ());
WorkerThread = new Thread (new ThreadStart (ServiceWorkerMethod ));
WorkerThread. Start ();
}

Protected override void OnStop ()
{
ReciveDataStatus. StopReviceDate = true;
}

Public void ServiceWorkerMethod ()
{
Sub. StartSubscriber ();
}

Note:

Sub. StartSubscriber () subscribes to ICE Storm. You need to create a delegate and subscribe to ICE storm server,
At the same time, a local listener is used to implement callback.

Symptoms:
Currently, the following problems occur: the callback function cannot be executed.
At the same time, it is found that the listening end of the local machine is listening, and sub. StartSubscriber (); also runs normally,

The test shows that the callback is normal in the windows form project.

Q: Is the windows Service Program in conflict with remote method calls or callbacks?

No WINDOWS service programs have been developed, so

It has been plagued for nearly two weeks, and no solution has been found.

Re-Project Creation still does not work

You cannot write a small service program for debugging. No!

Suddenly I want to try another machine and run it on my colleague's computer? Yes, it's depressing.

Look back, windows Firewall is on, close immediately, OK, dizzy, depressed ing!

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.