Exemplo n.º 1
0
 private static void UpdateRemoveableTasks()
 {
     for (int i = 0; i < Tasks.Count; i++)
     {
         QueedTask task = Tasks[i];
         if (task.IsReady)
         {
             Trace.TraceInformation("Task is ready");
             try
             {
                 if (ThreadPool.QueueUserWorkItem(task.callback, task.State))
                 {
                     lock (Tasks)
                     {
                         Trace.TraceInformation("Removing task");
                         Tasks.RemoveAt(i);
                         i--;
                     }
                 }
             }
             catch (ThreadAbortException ex)
             {
                 throw ex;
             }
             catch (Exception e)
             {
                 Console.WriteLine(e);
             }
         }
     }
 }
Exemplo n.º 2
0
        public static void Spawn(uint npcid, byte map, float x, float y, float z)
        {
            Zone zone;
            if (Singleton.Zones.TryGetZone(map, out zone))
            {
                MapObject regionObject = null;
                System.Threading.WaitCallback callback = delegate(object state)
                {
                    Singleton.Templates.UnspawnInstance(regionObject);
                    GC.Collect(0, GCCollectionMode.Optimized);
                };

                if (Singleton.Templates.SpawnNpcInstance(npcid, new Point(x, y, z), new Rotator(0, 0), zone, false, out regionObject))
                {
                    QueedTask timer = new QueedTask(callback, regionObject, 300000);
                }
            }
        }