protected void _onQueuedTaskFin(ITask t) { lock (_taskLock) { // remove task _tasks.Remove(t.id); // remove task record in session AESessionTask st = (AESessionTask)t; ((AESession)st.assocSession).removeTask(st); } }
public ITask queueTask(ISession session, ITask t) { if (!(session is AESession) || !(t is AESessionTask)) { session.lastErrorCode = AEErrorCode.ERR_SESSION_QUEUE_TASK_ERROR; session.lastErrorMsg = "AEServer session manager queueSessionTask session[" + AESession.dumpSessionInfo(session) + "] is not AESession or task[" + t + "] is not AESessionTask"; Debug.logger.log(LogType.LOG_WARNNING, session.lastErrorMsg); return(null); } AESession aeses = (AESession)session; AESessionTask aest = (AESessionTask)t; // new task t.addOnFinishCallback(_onQueuedTaskFin); int taskCount = 0; // record task lock (_taskLock) { _tasks[t.id] = t; taskCount = _tasks.Count; } // record task in session aeses.addTask(aest); //Console.WriteLine(aest.assocSession.sessionID + ":" + aest.assocSession.lastActiveTime); // dispatch task int idx = _getThreadIndexBySession(session); _threads[idx].queueTask(t); // change task status aest.onQueued(); return(t); }