private void RunRole(Type workerRoleType) { _workerRole = (RoleEntryPoint)Activator.CreateInstance(workerRoleType); if (!_workerRole.OnStart()) { Trace.TraceError("Role failed to start for '{0}'", workerRoleType); return; } try { if (workerRoleType.Name.Contains("WebRole")) { Trace.TraceInformation("HostRunner: Will not call Run() on WebRole, waiting for thread control."); try { Task.Delay(-1, LightBlueThreadControl.CancellationToken).Wait(); } catch (AggregateException) { Trace.TraceError("HostRunner: Cancellation requested, terminating."); } catch (OperationCanceledException) { Trace.TraceError("HostRunner: Cancellation requested, terminating."); } } else { _workerRole.Run(); } } finally { _workerRole.OnStop(); } }
public void Stop() { _role.OnStop(); Trace.TraceInformation("Worker host service restarting"); }