Beispiel #1
0
 /// <remarks/>
 public void updateAsync(zObject[] zObjects, object userState) {
     if ((this.updateOperationCompleted == null)) {
         this.updateOperationCompleted = new System.Threading.SendOrPostCallback(this.OnupdateOperationCompleted);
     }
     this.InvokeAsync("update", new object[] {
                 zObjects}, this.updateOperationCompleted, userState);
 }
Beispiel #2
0
 /// <remarks/>
 public void updateAsync(zObject[] zObjects) {
     this.updateAsync(zObjects, null);
 }
Beispiel #3
0
 /// <remarks/>
 public void generateAsync(zObject[] zObjects) {
     this.generateAsync(zObjects, null);
 }
Beispiel #4
0
 /// <remarks/>
 public void createAsync(zObject[] zObjects) {
     this.createAsync(zObjects, null);
 }
Beispiel #5
0
 private string update(zObject acc)
 {
     SaveResult[] result = binding.update(new zObject[] { acc });
     return result[0].Id;
 }
Beispiel #6
0
        //
        //given any size query handles the breaking it into numToDelete and handiling the numThreads
        //
        public void handleQuery(zObject[] objs)
        {
            zObject[] temp = objs;
            int size = temp.Length;

            List<string> ids = new List<string> { };

            locks = new List<ManualResetEvent>();
            ManualResetEvent evt;
            ThreadPool.SetMaxThreads(numThreads, numThreads);
            ThreadPool.SetMinThreads(1, 1);
            //
            //make lists not greater than NumToDelete and then delete them and reset the list
            //
            for(int i = 0; i < temp.Length; i++)
            {
                //Console.WriteLine("adding id: " + temp[i].Id);
                ids.Add(temp[i].Id);
                //
                //delte when ids.Count == numToDelete and there is a thread ready
                //
                if (ids.Count == numToDelete || i==temp.Length-1)
                {
                    Console.WriteLine("Delete" + i);
                    evt = new ManualResetEvent(false);
                    ThreadPool.QueueUserWorkItem(new WaitCallback(deleteList), (object)(new object[] { ids, evt }));
                    locks.Add(evt);

                    //Console.ReadKey();
                    int worker;
                    int async;
                    ThreadPool.GetAvailableThreads(out worker, out async);
                    //Console.WriteLine("Avail workers:" + worker);
                    if (locks.Count >= numThreads || worker == 0)
                    {

                        Console.WriteLine("Waiting for threads to finish" + " " + DateTime.Now.TimeOfDay);
                        EventWaitHandle.WaitAll(locks.ToArray());
                        Thread.Sleep(5);
                        ThreadPool.GetAvailableThreads(out worker, out async);
                        Console.WriteLine(" Number of Threads: " + numThreads + " " + DateTime.Now.TimeOfDay);
                        //Console.ReadKey();
                        locks = new List<ManualResetEvent> { };
                    }

                    ids = new List<string> { };
                }

            }
        }