/// <summary> /// Will never receive both parms - either both will be null or only one will be set. /// </summary> /// <param name="pTracePublisherURL">Remote Publisher uri</param> /// <param name="pTracePublisher">Existing local publisher</param> private void Subscribe(String pTracePublisherURL, TracePublisher pTracePublisher) { mRemoteTracePublisherURL = pTracePublisherURL; string publisherName = GetPublisherName(true); lock (this) { InvokeCaptureTraceMessage(new TraceMessage(null, "Attempting connection to " + publisherName, false)); try { if (pTracePublisher != null) { mTraceSubscriber.StartSubscription(pTracePublisher); } else if (!string.IsNullOrEmpty(pTracePublisherURL)) { mTraceSubscriber.StartSubscription(pTracePublisherURL); } else { mTraceSubscriber.StartSubscription(); } InvokeCaptureTraceMessage(new TraceMessage(null, "Connected to " + publisherName, false)); } catch (Exception ex) { InvokeCaptureTraceMessage(new TraceMessage(null, string.Format("Error connecting to {0}. Error: {1}", publisherName, ex.Message), false)); } if (IsRemotePublisher && mTimer == null) { mTimer = new System.Threading.Timer(new TimerCallback(PingTimerCallback), null, PingPublisherSeconds * 1000, PingPublisherSeconds * 1000); } } InvokeUpdateUI(); }
/// <summary> /// Create a new TraceViewerForm subscribed to the specified <see cref="TracePublisher"/>. /// </summary> /// <param name="pTracePublisher"></param> /// <remarks> /// Internal use only. /// </remarks> public TraceViewerForm(TracePublisher pTracePublisher) { Initialize(); Subscribe(null, pTracePublisher); }