Exemplo n.º 1
0
        /// <summary>Extent the initialization process.</summary>
        /// <param name="order"></param>
        /// <param name="status"></param>
        /// <param name="task"></param>
        public void RegisterInitializationTask(int order, string status, Func <Task> task)
        {
            if (status == null)
            {
                status = String.Empty;
            }

            lock (initializationTasks)
            {
                var initTask = new InitializationTask()
                {
                    Order = order, Status = status, Task = task
                };

                var index = initializationTasks.BinarySearch(initTask);
                if (index < 0)
                {
                    initializationTasks.Insert(~index, initTask);
                }
                else
                {
                    while (index < initializationTasks.Count && initializationTasks[index].Order == initTask.Order)
                    {
                        index++;
                    }
                    initializationTasks.Insert(index, initTask);
                }
            }
        }         // proc RegisterInitializationTask
Exemplo n.º 2
0
 private void DisposeInitializationTaskIfRequired()
 {
     lock (TaskManager)
     {
         if (InitializationTask != null)
         {
             InitializationTask.Dispose();
             InitializationTask = null;
         }
     }
 }