static void Main() { AppLog = new Ultra.Log.ApplicationLog(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.ThreadException += Application_ThreadException; var config = new HttpSelfHostConfiguration("http://localhost:30000"); config.MessageHandlers.Add(new FileHandler()); config.MaxReceivedMessageSize = 2147483647;//允许接收的文件大小 //TokenInspector tokenInspector = new TokenInspector() { // InnerHandler = // new System.Web.Http.Dispatcher.HttpControllerDispatcher(config) //}; config.Routes.MapHttpRoute( "Default", "api/{controller}/{id}", new { id = RouteParameter.Optional } //, constraints: null //, handler: null ); try { using (HttpSelfHostServer server = new HttpSelfHostServer(config)) { server.OpenAsync().Wait(); AppLog.DebugException(new Exception("PortNumber:30000")); var t = new Thread(() => { while (true) { Thread.Sleep(30 * 60 * 1000); GC.Collect(); } }); t.IsBackground = true; t.SetApartmentState(ApartmentState.STA); t.Start(); t.Join(); } } catch (Exception ex) { AppLog.DebugException(ex); } }
static void Main() { AppLog = new Ultra.Log.ApplicationLog(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.ThreadException += Application_ThreadException; var config = new HttpSelfHostConfiguration("http://localhost:30000"); config.MessageHandlers.Add(new FileHandler()); config.MaxReceivedMessageSize = 2147483647;//允许接收的文件大小 //TokenInspector tokenInspector = new TokenInspector() { // InnerHandler = // new System.Web.Http.Dispatcher.HttpControllerDispatcher(config) //}; config.Routes.MapHttpRoute( "Default", "api/{controller}/{id}", new { id = RouteParameter.Optional } //, constraints: null //, handler: null ); try { using (HttpSelfHostServer server = new HttpSelfHostServer(config)) { server.OpenAsync().Wait(); AppLog.DebugException(new Exception("PortNumber:30000")); var t = new Thread(() => { while (true) { Thread.Sleep(30 * 60 * 1000); GC.Collect(); } }); t.IsBackground = true; t.SetApartmentState(ApartmentState.STA); t.Start(); t.Join(); } } catch (Exception ex) { AppLog.DebugException(ex); } }
static void Main() { AppLog = new Ultra.Log.ApplicationLog(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); var tskid = Clear(); if (tskid > 0) { GetTaskStatus(tskid); } else { AppLog.DebugException(new Exception("Clear Task Fail.")); } }
static void Main() { AppLog = new Ultra.Log.ApplicationLog(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); int sec = 0; bool trc; string filepath; var conn = Init(out sec, out trc, out filepath); RunToDb r = new RunToDb(conn, AppLog, filepath, sec); r.Trace = trc; r.StartSync(); AppLog.DebugException(new Exception("Sync Start")); var t = new Thread(() => { while (true) { GC.Collect(); Thread.Sleep(5000); } }); t.IsBackground = true; t.Start(); t.Join(); }
static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) { MessageBox.Show(e.Exception.ToString(), "系统异常"); AppLog.DebugException(e.Exception); }
static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) { AppLog.DebugException(e.Exception); }