示例#1
0
        /// <summary>
        /// Sync aion chat.log.
        /// </summary>
        private void SyncChatLog()
        {
            FS?.Dispose();
            Reader?.Dispose();
            ChatLogWatcher?.Dispose();

            if (!string.IsNullOrEmpty(ChatLogPath) && !File.Exists(ChatLogPath))
            {
                ChatLogPath = "";
                return;
            }

            FS     = new FileStream(ChatLogPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            Reader = new StreamReader(FS, Encoding.Default);
            Reader.ReadToEnd();

            ChatLogWatcher = new FileSystemWatcher
            {
                Path                = Path.GetDirectoryName(ChatLogPath),
                NotifyFilter        = NotifyFilters.LastWrite,
                Filter              = "Chat.log",
                EnableRaisingEvents = true
            };
            ChatLogWatcher.Changed += ChatLog_Changed;
        }
示例#2
0
        /// <summary>
        /// Dispose all resources.
        /// </summary>
        public new void Dispose()
        {
            foreach (ConsoleControl.ConsoleControl chat in Chats.Values)
            {
                chat?.Dispose();
            }
            SelectedChat = null;
            Chats        = null;
            ChatLogWatcher?.Dispose();
            ChatLogWatcher = null;
            Reader?.Dispose();
            Reader = null;
            FS?.Dispose();
            FS = null;
            NotifyIcon?.Dispose();
            NotifyIcon = null;

            base.Dispose();
        }