/[RomCheater]/trunk/RomCheater/Docking/FloatingMemorySearcher.cs
ViewVC logotype

Diff of /trunk/RomCheater/Docking/FloatingMemorySearcher.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/RomCheater/Docking/FloatingMemorySearcher.cs	2013/06/05 21:00:53	542
+++ trunk/RomCheater/Docking/FloatingMemorySearcher.cs	2013/06/05 22:00:27	544
@@ -1510,6 +1510,15 @@
                                         StructResultType<ulong> result = StructResultType<ulong>.Empty;
                                         reader.GetResultAtIndex(ResultChunkIndex, SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress), out result, new Func<bool>(ShouldCancelAnySearchOperation));
                                         ChunkResults[ChunkIndex] = result;
+                                        if (SearchWorkerThread.CancellationPending)
+                                        {
+                                            provider_st.Stop();
+                                            st.Stop();
+                                            writer.CancelRequest();
+                                            writer.Dispose();
+                                            e.Result = true;
+                                            break;
+                                        }
                                     }
                                     // Get update value(s) for each chunk result
                                     ISerializedResult sr = (reader as ISerializedResult);
@@ -1521,13 +1530,23 @@
                                     Stopwatch st_memory_results_updater = new Stopwatch();
                                     st_memory_results_updater.Start();
                                     sr.UpdateResultValuesFromMemory(ref ChunkResults, SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress), new Func<bool>(ShouldCancelAnySearchOperation), (IAcceptsProcessAndConfig)this);
+                                    if (SearchWorkerThread.CancellationPending) // catch a cancelled operation from UpdateResultValuesFromMemory
+                                    {
+                                        provider_st.Stop();
+                                        st.Stop();
+                                        writer.CancelRequest();
+                                        writer.Dispose();
+                                        e.Result = true;
+                                        break;
+                                    }
+
                                     st_memory_results_updater.Stop();
                                     logger.Profiler.WriteLine("sr.UpdateResultValuesFromMemory [ResultIndex=0x{0} ChunkCount=0x{1}] took a total of {2} seconds to complete", ResultIndex.ToString("X"), ChunkCount.ToString("X"), st_memory_results_updater.Elapsed.TotalSeconds.ToString());
 
                                     // ChunkResults should have had thier values updated from memory
 
 
-                                    string message = string.Format(" -> Updateing values from index 0x{0} to 0x{1}", ResultIndex.ToString("X"), ChunkCount.ToString("X"));
+                                    string message = string.Format(" -> Updateing Values [ResultIndex=0x{0} of Total=0x{1}]", ResultIndex.ToString("X"), reader.ResultCount.ToString("X"));
                                     double double_percent_done = 100.0 * (double)((double)ResultIndex / (double)reader.ResultCount);
                                     int int_percent_done = (int)double_percent_done;
                                     //if ((int_percent_done != Last_Whole_Percent_Done) && (index % 1000) == 0)
@@ -1535,12 +1554,21 @@
                                     //    UpdateProgress((int)double_percent_done, message);
                                     //    Last_Whole_Percent_Done = int_percent_done;
                                     //}
-                                    if ((ResultIndex % 10000) == 0)
+                                    if (((double)ResultIndex % ((double)reader.ResultCount) * 0.25) == 0)
+                                    //if ((ResultIndex % 10000) == 0)
                                     {
                                         UpdateProgress((int)double_percent_done, message);
                                         Last_Whole_Percent_Done = int_percent_done;
                                     }
-
+                                    if (SearchWorkerThread.CancellationPending)
+                                    {
+                                        provider_st.Stop();
+                                        st.Stop();
+                                        writer.CancelRequest();
+                                        writer.Dispose();
+                                        e.Result = true;
+                                        break;
+                                    }
                                 }
 
                                 #region old-code

 

  ViewVC Help
Powered by ViewVC 1.1.22