/// <summary> /// Process the current outstanding list of operations /// </summary> protected bool ProcessOperations() { // If no more operations simply return false now if (_listOutstandingOperations.Count == 0) { return(false); } // Create a log file LogFile ourLog = LogFile.Instance; // We use a separate thread for each upto a maximum of 10 threads // If we have exceeded the thread limit then we need to wait for one to become availab;e if (_threadPool.Count >= MAX_THREADS) { return(false); } // We have a spare entry in the Thread pool - allocate it and pass the operation to the thread to perform OperationThreadData operationThreadData = new OperationThreadData(); operationThreadData.ActiveOperation = _listOutstandingOperations[0]; operationThreadData.ActiveOperation.Status = Operation.STATUS.pending; ourLog.Write("Processing Operation for " + operationThreadData.ActiveOperation.AssetName, true); // remove the operation from the list now that we have allocated it to a thread _listOutstandingOperations.RemoveAt(0); // Add the OperationThreadData to the thread pool _threadPool.Add(operationThreadData); // Mark the operation as 'Pending' in the database OperationsDAO lwDataAccess = new OperationsDAO(); lwDataAccess.OperationUpdate(operationThreadData.ActiveOperation); // Create the actual Windows Thread and start it passing the OperationThreadData object as a parameter BackgroundWorker operationThread = new System.ComponentModel.BackgroundWorker(); operationThread.WorkerReportsProgress = false; operationThread.DoWork += new System.ComponentModel.DoWorkEventHandler(operationThread_DoWork); operationThread.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(operationThread_WorkerCompleted); operationThread.RunWorkerAsync(operationThreadData); //Thread thread = new Thread(new ParameterizedThreadStart(PerformOperation)); //thread //thread.Start(operationThread); return(true); }
/// <exception cref="InvalidOperationException"> /// The type does not support the given kind of member. /// </exception> public void InsertMember(MemberType type, int index) { if (type == MemberType.Field) { if (index > FieldCount) { index = FieldCount; } } else { index -= FieldCount; if (index > OperationCount) { index = OperationCount; } } if (index < 0) { index = 0; } switch (type) { case MemberType.Field: Field field = AddField(); FieldList.RemoveAt(FieldCount - 1); FieldList.Insert(index, field); break; case MemberType.Method: Method method = AddMethod(); OperationList.RemoveAt(OperationCount - 1); OperationList.Insert(index, method); break; case MemberType.Constructor: Constructor constructor = AddConstructor(); OperationList.RemoveAt(OperationCount - 1); OperationList.Insert(index, constructor); break; case MemberType.Destructor: Destructor destructor = AddDestructor(); OperationList.RemoveAt(OperationCount - 1); OperationList.Insert(index, destructor); break; case MemberType.Property: Property property = AddProperty(); OperationList.RemoveAt(OperationCount - 1); OperationList.Insert(index, property); break; case MemberType.Event: Event _event = AddEvent(); OperationList.RemoveAt(OperationCount - 1); OperationList.Insert(index, _event); break; } }