static void Main() { bool newInstance; using (Mutex mutex = new Mutex(false, "VCover", out newInstance)) { if (newInstance) { try { ThreadPool.SetMaxThreads(50, 100); Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-us"); StartUp.TryToAddAppSafe(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Application.ThreadException += new ThreadExceptionEventHandler(OnThreadException); var ctn = new AppContext(); ctn.NewInFileEvent += new EventHandler <ValueEventArgs <Guid, string> >(NewCommandFileEvent); ctn.Started += new EventHandler(ctn_Started); StateSaver.Error += new ThreadExceptionEventHandler(OnThreadException); AppContext.Default.Error += new ThreadExceptionEventHandler(OnThreadException); StateSaver.Default.Path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "VCover.dat"); StateSaver.Default.Load(); TemplateMatcher.Path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "TemplateMatcher.dat"); TemplateMatcher.Load(); NamedPipes.ReceivedData += new ReceivedDataDelegate(NamedPipes_ReceivedData); NamedPipes.Error += new ThreadExceptionEventHandler(OnThreadException); NamedPipes.StartServer("VCOVER"); Application.Run(ctn); } finally { StateSaver.Default.Save(); TemplateMatcher.Save(); } } else { MessageBox.Show("An instance is already started.\r\nPlease close it first.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
public void Run() { StateSaver.Default.Set(Strings.USE_VCOVER, true); var prtReadData = ms_ReadDataDelegate.GetFunctionPointer(); StateSaver.Default.Set(Strings.VCOVER_FUNC, prtReadData); NamedPipes.ReceivedData += new ReceivedDataDelegate(NamedPipes_ReceivedData); NamedPipes.Error += new ThreadExceptionEventHandler(NamedPipes_Error); NamedPipes.StartServer("VPRINT"); }
public MainViewModel() { BrowseCommand = new RelayCommand(Browse); ApplyCommand = new RelayCommand(Apply); CancelCommand = new RelayCommand(Cancel); SkipCommand = new RelayCommand((arg) => Continue()); SearchEngine.Initialize(); SearchEngine.SearchCompleted += (args) => { Covers = args; IsSearching = false; }; NamedPipes.MessageReceived += NamedPipes_MessageReceived; NamedPipes.StartServer(); }
/// <summary> /// Recieves messages from the NXMWorker and routes them back to the calling method by IProgress. /// </summary> /// <param name="progress"></param> public void StartRecievingProtocolValues(IProgress <CaptureProtocolValuesProgress> progress) { var namedPipes = new NamedPipes(new Progress <string>(protocolResponse => { var splitProtocolResponse = protocolResponse.Replace("nxm://", "") .Split('/'); if (true || splitProtocolResponse[0].ToLower() == ModpackHeader.TargetGame) { var progressObject = new CaptureProtocolValuesProgress() { ModId = splitProtocolResponse[2], FileId = splitProtocolResponse[4] }; // Report back to the calling method progress.Report(progressObject); } })); namedPipes.StartServer(); }