Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Runtime.Serialization;
- using System.ServiceModel;
- using System.Text;
- using Microsoft.WindowsAzure.ServiceRuntime;
- using SignalR.Client.Hubs;
- using SiteMonitR.WorkerRole;
- using System.Threading;
- using System.Net;
- using SiteMonitR.WorkerRole.Properties;
- namespace SiteMonitR.Web
- {
- public class Service1 : IService1
- {
- Thread thread;
- Server server;
- public Service1()
- {
- 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();
- Run();
- }
- public void Run()
- {
- Trace.WriteLine("SiteMonitR.WebRole entry point called", "Information");
- while (true)
- {
- Thread.Sleep(Settings.Default.PingTimeout);
- server.Run();
- }
- }
- ~Service1()
- {
- thread.Abort();
- server.Stop();
- Debug.WriteLine("Stopped service");
- }
- public int GetResponse()
- {
- // TODO: Implement this method
- var result = 0;
- try
- {
- server.DoSomething("mensaje de respuesta");
- }
- catch (Exception ex)
- {
- Console.WriteLine("Error returned: " + ex.Message);
- }
- return result;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement