ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/RomCheater/trunk/RomCheater/Docking/FloatingMemorySearcher.cs
(Generate patch)

Comparing trunk/RomCheater/Docking/FloatingMemorySearcher.cs (file contents):
Revision 445 by william, Sun Jun 2 19:21:16 2013 UTC vs.
Revision 446 by william, Sun Jun 2 19:52:03 2013 UTC

# Line 1044 | Line 1044 | namespace RomCheater.Docking
1044          }
1045          private void search_provider_OnBytesRead(OnBytesReadEventArgs e)
1046          {
1047 +            if (SearchWorkerThread.CancellationPending) { e.Canceled = true; return; }
1048              SearchDataTypes sdt = SearchArgs.DataType;
1049              bool unsigned = SearchArgs.IsUnsignedDataType;
1050              int Last_Whole_Percent_Done = 0;
# Line 1076 | Line 1077 | namespace RomCheater.Docking
1077                                          if (unsigned) { writer.WriteResult<UInt64>((uint)CurrentIndex, br.ReadUInt64()); }
1078                                          else { writer.WriteResult<Int64>((uint)CurrentIndex, br.ReadInt64()); } break;
1079                                  }
1080 +                                if (SearchWorkerThread.CancellationPending) { e.Canceled = true; return; }
1081                              }
1082                              catch (EndOfStreamException) { }
1083                              double double_percent_done = 100.0 * (double)((double)CurrentIndex / (double)e.TotalCount);
# Line 1088 | Line 1090 | namespace RomCheater.Docking
1090                                      resultsprogress.Message = string.Format(" -> Reading Address: 0x{0:x8}", (CurrentIndex + MemoryRangeStart));
1091                                      Last_Whole_Percent_Done = int_percent_done;
1092                                  }
1093 +                                if (SearchWorkerThread.CancellationPending) { e.Canceled = true; return; }
1094                              }
1095                              switch (sdt)
1096                              {
# Line 1109 | Line 1112 | namespace RomCheater.Docking
1112                      }
1113                  }
1114              }
1115 +            if (SearchWorkerThread.CancellationPending) { e.Canceled = true; return; }
1116          }
1117          private void SearchWorkerThread_DoWork(object sender, DoWorkEventArgs e)
1118          {
# Line 1145 | Line 1149 | namespace RomCheater.Docking
1149                      provider.OnBytesRead += new BaseEventHandler<OnBytesReadEventArgs>(search_provider_OnBytesRead);
1150                      provider.ReadProcessMemoryAtOnce(MemoryRangeStart, (MemoryRangeSize - MemoryRangeStart), writer);
1151                      provider.CloseProvider();
1152 +                    if (SearchWorkerThread.CancellationPending) { provider_st.Stop(); st.Stop(); writer.CancelRequest(); e.Result = true; return; }
1153                      writer.Dispose();
1154                  }
1155                  provider_st.Stop();
# Line 1725 | Line 1730 | namespace RomCheater.Docking
1730  
1731          private void SearchWorkerThread_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
1732          {
1733 <            if (!e.Cancelled)
1733 >            try { if ((bool)e.Result) { logger.Warn.WriteLine("Search operation was cancelled."); resultsprogress.Value = 0; resultsprogress.Message = ""; return; } }
1734 >            catch (InvalidCastException) { }
1735 >            try
1736              {
1737 <                Stopwatch st = (e.Result as Stopwatch);
1737 >                Stopwatch st = (Stopwatch)e.Result;
1738                  st.Stop();
1739                  logger.Profiler.WriteLine("Search took {0} seconds, overall, to complete.", st.Elapsed.TotalSeconds);
1740              }
1741 <            
1741 >            catch (InvalidCastException) { }
1742 >            catch (Exception ex) { throw ex; }
1743 >
1744              resultsprogress.Value = 100;
1745              bool unsigned = SearchArgs.IsUnsignedDataType;
1746              using (SearchResultReader reader = new SearchResultReader(SearchGuid))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines