public override void Close() { if (!_configuredWell) { return; } if (!_disposed && _publisher != null && _publisher.State != State.Closed) { _publisher.Close(); } _stream.Close(); }
public void Close() { try { if (Publisher.State != State.Closed) { m_publisher.Close(); // m_publisher.Dispose(); } } catch (Exception e) { string err = "Unable to close or dispose publisher. "; Log(err + e.Message); Error(err, e); } }
public static void Main(string [] args) { for (int i = 0; i < args.Length; i++) { if (args[i].Equals("--username") || args[i].Equals("-u")) { if (i + 1 < args.Length && !args[i + 1].StartsWith("-")) { username = args[++i]; } else { Usage(); } } else if (args[i].Equals("--password") || args[i].Equals("-p")) { if (i + 1 < args.Length && !args[i + 1].StartsWith("-")) { password = args[++i]; } else { Usage(); } } else if (args[i].Equals("--destination") || args[i].Equals("-d")) { if (i + 1 < args.Length && !args[i + 1].StartsWith("-")) { destination = args[++i]; } else { Usage(); } } else if (args[i].Equals("--count") || args[i].Equals("-c")) { if (i + 1 < args.Length && !args[i + 1].StartsWith("-")) { count = Int32.Parse(args[++i]); } else { Usage(); } } else if (args[i].Equals("--rate") || args[i].Equals("-r")) { if (i + 1 < args.Length && !args[i + 1].StartsWith("-")) { rate = Int32.Parse(args[++i]); } else { Usage(); } } else if (args[i].StartsWith("-")) { Usage(); } else { url = args[i]; } } Console.Write("#\n# Publisher\n#\n# {0}\n#\n", EFTL.GetVersion()); try { Publisher client = new Publisher(url, username, password); try { if (client.IsConnected()) { client.Publish(destination, count, rate); } } finally { client.Close(); } } catch (Exception e) { Console.WriteLine(e.ToString()); } }