private void TaskClear(bool cleanproc = false) { if (!this._TaskDisposed) { this._TaskDisposed = true; if (this._task != null) { while ((!this._task.IsCanceled) && (!this._task.IsCompleted) && (!this._task.IsFaulted)) { if (this._canceler != null) { this._canceler.Cancel(); } this._task.Wait(); } this._task.Dispose(); this._task = null; if (this.isLogEnable) { this._ilog.LogInfo( string.Format( Properties.Resources.ShedStopProcess, DateTime.Now.ToString() ) ); } } if (this._canceler != null) { this._canceler.Dispose(); this._canceler = null; } this._TaskDisposed = false; if ((cleanproc) && (this._cocProcess != null)) { this._cocProcess.Dispose(); this._cocProcess = null; } } }
private void _Init(string dbname, string dbopt, string key, string clantag, string curlexe, string rootpath, stCore.IMessage ilog, bool isnotify) { try { if (string.IsNullOrWhiteSpace(dbname)) { dbname = CoCAPI._dbName; } this._ilog = ilog; this._key = key; this._clantag = clantag; this._curlexe = curlexe; this._rootpath = ((string.IsNullOrWhiteSpace(rootpath)) ? stCore.IOBaseAssembly.BaseDataDir() : rootpath ); this._dbm = new stSqlite.Wrapper(dbname, dbopt); if (this._dbm == null) { throw new ArgumentNullException( string.Format( Properties.Resources.CoCInitError, typeof(stSqlite.Wrapper).Name, 0 ) ); } this._dbm.RegisterFunction(typeof(SelectLeagueIcoFunction)); this._dbm.RegisterFunction(typeof(SelectBadgeIcoFunction)); this._dbm.RegisterFunction(typeof(SelectFlagIcoFunction)); this._dbm.RegisterFunction(typeof(ComputePasswordHashFunction)); this._cocProcess = new stCoCAPI.CoCAPI.CoCProcess(this); if (this._cocProcess == null) { throw new ArgumentNullException( string.Format( Properties.Resources.CoCInitError, typeof(CoCProcess).Name, 1 ) ); } this._cocProcess.CheckTable(); this._cocInformer = new stCoCAPI.CoCAPI.CoCInformer(this); if (this._cocInformer == null) { throw new ArgumentNullException( string.Format( Properties.Resources.CoCInitError, typeof(CoCInformer).Name, 2 ) ); } if (isnotify) { this._cocRrd = new CoCRrd(this); if (this._cocRrd == null) { throw new ArgumentNullException( string.Format( Properties.Resources.CoCInitError, typeof(CoCRrd).Name, 3 ) ); } this._cocNotifier = new CoCNotify(this); if (this._cocNotifier == null) { throw new ArgumentNullException( string.Format( Properties.Resources.CoCInitError, typeof(CoCNotify).Name, 4 ) ); } } #if DEBUG_PRNTABLE DataTable dt1 = this._dbm.Query("SELECT * FROM clanwar"); dt1.DataTableToPrint(); #endif } catch (Exception e) { stCore.LogException.Error(e, this._ilog); return; } }