/// <summary> /// Restores the queue will all received messages (some of them were sent on the first subscription). /// Subscribes the hub channel to the queue. /// </summary> /// <param name="subscriber"></param> public void SubscribeResume(WorkflowHubSubscriber subscriber) { Volatile.Write(ref _subscriber, subscriber); //RestoreOlder uses an internal lock. The collection will not suffer changes while restoration is in progress Messages.RestoreOlder(); TrySendMessagesInternal(); }
public void Dispose() { _subscriber = null; InstanceDone = null; //https://stackoverflow.com/questions/153573/how-can-i-clear-event-subscriptions-in-c Messages.Clear(); //if was called, finalizer no longer needed GC.SuppressFinalize(this); }
/// <summary> /// A <see cref="WorkflowHubSubscriber"/> which contains the actions that send messages to the client is passed. /// <para>A <see cref="WorkflowBusSubscriber"/> is created and <see cref="WorkflowHubSubscriber"/> subscribes to it</para> /// </summary> /// <param name="correlationId">The correlation if for which the <see cref="WorkflowBusSubscriber"/> is created</param> /// <param name="clientSubscriber">The signalR subscriber</param> /// <param name="correlatedInstance">The service bus subscriber</param> public void WorkflowRelayStart(string correlationId, WorkflowHubSubscriber clientSubscriber, out WorkflowBusSubscriber correlatedInstance) { WorkflowBusSubscriber instance = new WorkflowBusSubscriber(correlationId); _correlatedInstances.TryAdd(correlationId, instance); instance.Subscribe(clientSubscriber); correlatedInstance = instance; }
// <summary> /// A <see cref="WorkflowHubSubscriber"/> which contains the actions that send messages to the client is passed. /// <para>A <see cref="WorkflowBusSubscriber"/> is searched in the list of saved subscribers /// </summary> /// <param name="correlationId">The correlation if for which the <see cref="WorkflowBusSubscriber"/> is created</param> /// <param name="clientSubscriber">The signalR subscriber</param> /// <param name="correlatedInstance">The service bus subscriber</param> /// <returns>Returns true if a busSubscriber was found. False otherwhise</returns> public bool WorkflowRelayResume(string correlationId, WorkflowHubSubscriber clientSubscriber, out WorkflowBusSubscriber correlatedInstance) { _correlatedInstances.TryGetValue(correlationId, out WorkflowBusSubscriber _correlatedInstance); if (!(_correlatedInstance is null)) { _correlatedInstance.SubscribeResume(clientSubscriber); correlatedInstance = _correlatedInstance; return(true); } correlatedInstance = null; return(false); }
public void Subscribe(WorkflowHubSubscriber subscriber) { Volatile.Write(ref _subscriber, subscriber); TrySendMessagesInternal(); }