public void Close() { if (isClosed) return; lock (this) { isClosing = true; Monitor.Pulse(this); } if (!thread.Join(2000)) { thread.Abort(); } if (connection != null) { connection.Close(); connection = null; while (queue.Count > 0) { Notification n = queue.Dequeue(); n.NotSend(); } } isClosed = true; }
private void Run() { logger.Debug("Service.Run start"); lock (this) { while (true) { while (!isConnectionAborting && !isClosing) { Monitor.Wait(this); } if (isClosing) { logger.Debug("Service.Run exit"); return; } connection.Close(); connection = null; if (archive.LastIdentifier != -1) { for (int i = errorNotificationIdentifier + 1; i <= archive.LastIdentifier; i++) { queue.Enqueue(archive.Get(i)); } } Connect(); logger.Debug("Service.Run Connection reconnect"); } } }
private void Connect() { isConnectionAborting = false; archive = new Archive(); string host; if (isSandbox) host = sandboxHost; else host = productHost; connection = new Connection(host, port, p12File, p12FilePassword, queue, archive, this); }