public void Test03() { ThreadCls cls0 = new ThreadCls(); ThreadCls cls1 = new ThreadCls(); Thread threadA = new Thread(cls0.RunThread); threadA.Name = "AAA"; Thread threadB = new Thread(cls1.RunThread); threadB.Name = "BBB"; threadA.Start(); threadB.Start(); Console.ReadLine(); }
public void ProcessGames(IEnumerable <Game> games, bool spiffycover, bool rename, int type, string path, string inactivepath) { _gamecnt = 0; Abort = false; Finished = false; ThreadCls cls = new ThreadCls(); cls.Games = new List <Game>(); cls.Games.AddRange(games); cls.SpiffyCover = spiffycover; cls.Rename = rename; cls.Type = type; cls.BasePath = path; cls.InactivePath = inactivepath; Thread th = new Thread(ExecutorThread); th.Start(cls); }
private void ExecutorThread(object obj) { ThreadCls cls = (ThreadCls)obj; threadcnt = 0; do { if (cls.Games.Count > 0) { Thread2Cls cls2 = new Thread2Cls(); lock (executorlock) { cls2.Game = cls.Games[0]; cls.Games.RemoveAt(0); } cls2.Rename = cls.Rename; cls2.SpiffyCover = cls.SpiffyCover; cls2.Type = cls.Type; cls2.BasePath = cls.BasePath; cls2.InactivePath = cls.InactivePath; Thread th = new Thread(RetrieveThread); th.Start(cls2); threadcnt++; } while (threadcnt == MAX_THREADS) { Thread.Sleep(50); } Thread.Sleep(50); } while (((cls.Games.Count > 0) || threadcnt > 0) && (!Abort)); Finished = true; if (this.OnFinish != null) { OnFinish.Invoke(); } }