internal static void LoadFromFileAsynch(string fileName, FileImportMethod style) { if (!File.Exists(fileName)) { return; } try { LoadFileDelegate d = new LoadFileDelegate(ReadMessagesFromFile); // TODO : FireAndForget support required so we dont leak like a bottomer. d.BeginInvoke(fileName, style, null, null); // We just let this happen in the background and dissapear when its done. } catch (IOException ex) { // OK what do we do about errors ? //Bilge.Dump(ex, "Error occured during LoadFromFileAsynch method"); MexCore.TheCore.ViewManager.AddUserNotificationMessageByIndex(ViewSupportManager.UserMessages.ErrorDuringfileImport, ViewSupportManager.UserMessageType.ErrorMessage, null); } }
public void BeginLoadFile(AsyncCallback callback) { LoadFileDelegate loadFileDelegate = new LoadFileDelegate(LoadFile); IAsyncResult result = loadFileDelegate.BeginInvoke(callback, null); }
public LogWindow AddFileTab(string givenFileName, bool isTempFile, string title, bool forcePersistenceLoading, ILogLineColumnizer preProcessColumnizer, bool doNotAddToDockPanel) { string logFileName = FindFilenameForSettings(givenFileName); LogWindow win = FindWindowForFile(logFileName); if (win != null) { if (!isTempFile) { AddToFileHistory(givenFileName); } SelectTab(win); return(win); } EncodingOptions encodingOptions = new EncodingOptions(); FillDefaultEncodingFromSettings(encodingOptions); LogWindow logWindow = new LogWindow(this, logFileName, isTempFile, forcePersistenceLoading); logWindow.GivenFileName = givenFileName; if (preProcessColumnizer != null) { logWindow.ForceColumnizerForLoading(preProcessColumnizer); } if (isTempFile) { logWindow.TempTitleName = title; encodingOptions.Encoding = new UnicodeEncoding(false, false); } AddLogWindow(logWindow, title, doNotAddToDockPanel); if (!isTempFile) { AddToFileHistory(givenFileName); } LogWindowData data = logWindow.Tag as LogWindowData; data.color = this.defaultTabColor; setTabColor(logWindow, this.defaultTabColor); //data.tabPage.BorderColor = this.defaultTabBorderColor; if (!isTempFile) { foreach (ColorEntry colorEntry in ConfigManager.Settings.fileColors) { if (colorEntry.fileName.ToLower().Equals(logFileName.ToLower())) { data.color = colorEntry.color; setTabColor(logWindow, colorEntry.color); break; } } } if (!isTempFile) { SetTooltipText(logWindow, logFileName); } if (givenFileName.EndsWith(".lxp")) { logWindow.ForcedPersistenceFileName = givenFileName; } // this.BeginInvoke(new LoadFileDelegate(logWindow.LoadFile), new object[] { logFileName, encoding }); LoadFileDelegate loadFileFx = new LoadFileDelegate(logWindow.LoadFile); loadFileFx.BeginInvoke(logFileName, encodingOptions, null, null); return(logWindow); }