public static void ThreadProc(object param) { try { DebugMod.Log("Logic Thread Start."); GameMain frame = param as GameMain; long prevTick = DateTime.Now.Ticks; if (null != param) { while (!m_AppExit) { long nowTick = DateTime.Now.Ticks; long elapseTick = nowTick - prevTick; if (elapseTick > 333333) //33ms { prevTick = nowTick; frame.OnThreadUpdate(); } } } DebugMod.Log("Logic Thread Exit."); } catch (Exception ex) { DebugMod.LogException(ex); } }
public void DownloadFile() { DebugMod.Log("asyDownload:" + m_Url); HttpWebRequest httpRequest = WebRequest.Create(m_Url) as HttpWebRequest; httpRequest.BeginGetResponse(new AsyncCallback(ResponseCallback), httpRequest); }
/// <summary> /// 获得csvmod加载的文件内容,并按照“前后名id”,放到NameContainer的各自的List中(0->只做前名,1->只做后名,2->前后名都可以做) /// NameContainer< <0, <前名...> > , <1, <后名...> , <2 ,<前/后...> > > /// </summary> private void InitNameDictionary() { if (0 == (tempList = csvmod.GetAllData()).Count)//若是没加载Name.csv文件,先加载. { if (!csvmod.LoadCsvStr()) { DebugMod.Log("Load NameFile Failed!"); } else { for (int index = 0; index < tempList.Count; index++) { int nameId = int.Parse(tempList[index]["前后代号"]); //前后代号:各种名字的id string name = tempList[index]["备用名字"]; // 代号对应的名字 if (NameContainer.ContainsKey(nameId)) { NameContainer[nameId].Add(name); } else { NameContainer.Add(nameId, new List <string>()); } } } } }
public void Init() { try { //创建逻辑线程 DebugMod.Log("GameMain Init"); OutLog.Instance.InitLog(); //Thread t = new Thread(new ParameterizedThreadStart(ThreadProc)); //t.Start(this); //Thread.Sleep(0); LogicActionFactory.Instance.ActionAssembly = System.Reflection.Assembly.GetCallingAssembly(); BattleManager.Instance.Init(); } catch (Exception ex) { DebugMod.LogException(ex); } }
public void Init() { GlobalObject = gameObject; try { //创建逻辑线程 DebugMod.Log("GameMain Init"); LuaScriptMgr.Instance.Init(); LuaScriptMgr.Instance.InitStart(); //Thread t = new Thread(new ParameterizedThreadStart(ThreadProc)); //t.Start(this); //Thread.Sleep(0); NetActionFactory.Instance.ActionAssembly = System.Reflection.Assembly.GetCallingAssembly(); } catch (Exception ex) { DebugMod.LogException(ex); } }
void ReadDataCallback(IAsyncResult ar) { WebReqState rs = ar.AsyncState as WebReqState; int read = rs.m_OrginalStream.EndRead(ar); if (read > 0) { rs.m_FileStream.Write(rs.m_Buffer, 0, read); rs.m_FileStream.Flush(); rs.m_OrginalStream.BeginRead(rs.m_Buffer, 0, WebReqState.m_BufferSize, new AsyncCallback(ReadDataCallback), rs); } else { rs.m_FileStream.Close(); rs.m_OrginalStream.Close(); rs.m_WebResponse.Close(); DebugMod.Log("http download url finish" + m_Url); } }