Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Diagnostics;
- using System.Linq;
- using System.Net;
- using System.Threading;
- using Microsoft.WindowsAzure.ServiceRuntime;
- using SiteMonitR.WorkerRole.Properties;
- namespace SiteMonitR.WorkerRole
- {
- public class WorkerRole : RoleEntryPoint, IService2
- {
- Thread thread;
- Server server;
- public int GetResponseWorker()
- {
- int result = 0;
- server.DoSomething("result is " + result);
- return result;
- }
- public override void Run()
- {
- Trace.WriteLine("SiteMonitR.WorkerRole entry point called", "Information");
- while (true)
- {
- Thread.Sleep(Settings.Default.PingTimeout);
- server.Run();
- }
- }
- public override bool OnStart()
- {
- ServicePointManager.DefaultConnectionLimit = 12;
- // create the server
- server = new Server(
- new TableStorageSiteUrlRepository(),
- new WorkerRoleHubConfiguration()
- );
- // run the server
- thread = new Thread(new ThreadStart(() => server.Run()));
- thread.Start();
- return base.OnStart();
- }
- public override void OnStop()
- {
- thread.Abort();
- server.Stop();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement