/// <summary> /// Start sending process. /// </summary> /// <param name="hostInfo">Current host information.</param> /// <returns>Is success?.</returns> public bool Start(IMndpHostInfo hostInfo) { try { var t = new Thread(this.SendHostInfoWork); this._sendHostInfoIsRunning = true; t.Start(); this._sendHostInfoThread = t; this._hostInfo = hostInfo; } catch (Exception ex) { Log.Exception(nameof(MndpSender), nameof(this.Start), ex); } return(false); }
/// <summary> /// Stop sending process. /// </summary> /// <returns>Is success?.</returns> public bool Stop() { try { if (this._sendHostInfoThread != null) { this._sendHostInfoIsRunning = false; if (this._sendHostInfoThread.IsAlive == true) { this._sendHostInfoIsRunning = false; this._sendHostInfoThread.Join(1000); } if (this._sendHostInfoThread.IsAlive == true) { this._sendHostInfoThread.Interrupt(); this._sendHostInfoThread.Join(1000); } if (this._sendHostInfoThread.IsAlive == true) { this._sendHostInfoThread.Abort(); } this._sendHostInfoThread = null; this._hostInfo = null; } } catch (Exception ex) { Log.Exception(nameof(MndpSender), nameof(this.Stop), ex); } return(false); }