/[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 03:23:27	516
+++ trunk/RomCheater/Docking/FloatingMemorySearcher.cs	2013/06/05 03:49:00	517
@@ -72,15 +72,17 @@
             IProgressMessage pm = (o as IProgressMessage);
             if (pm == null) { return; }
             resultsprogress.Value = pm.Progress;
-            resultsprogress.Message = pm.Message;           
+            resultsprogress.Message = pm.Message;
         }
 
         private void UpdateProgress(int progress, string message)
         {
             // detach the progress update from execution within the current thread (so it does not block a cpu-intensive or long running sequence)
             Thread t = new Thread(new ParameterizedThreadStart(thread_UpdateProgress));
-            t.SetApartmentState(ApartmentState.MTA);
+            t.SetApartmentState(ApartmentState.STA);
             t.Start(new ProgressMessage(progress, message));
+            //resultsprogress.Value = progress;
+            //resultsprogress.Message = message;
         }
 
         #region IAcceptsProcess<Process> Members
@@ -1437,16 +1439,16 @@
                     double double_percent_done = 100.0 * (double)((double)CurrentIndex / (double)e.TotalCount);
                     int int_percent_done = (int)double_percent_done;
 
-                    //int align_base = 1000;
-                    //int align_magnitude = 1;
-                    //int alignment = align_base * align_magnitude;
-                    if ((int_percent_done != Last_Whole_Percent_Done) )// && (CurrentIndex % alignment) == 0)
+                    double align_base = 1024;
+                    double align_magnitude = 0.25;
+                    double alignment = align_base * align_magnitude;
+                    if ((int_percent_done != Last_Whole_Percent_Done) && (CurrentIndex % alignment) == 0)
                     {
                         if (int_percent_done <= 100)
                         {
                             string message = string.Format(" -> Reading Address: 0x{0:x8} of 0x{1:x8}", (CurrentIndex + MemoryRangeStart), (CurrentIndex + MemoryRangeStart) + e.Data.Length);
-                            //UpdateProgress(int_percent_done, message);
-                            new Action<int, string>(UpdateProgress).Invoke(int_percent_done, message);
+                            UpdateProgress(int_percent_done, message);
+                            //new Action<int, string>(UpdateProgress).Invoke(int_percent_done, message);
                             Last_Whole_Percent_Done = int_percent_done;
                         }
                         if (SearchWorkerThread.CancellationPending) { e.Canceled = true; return; }
@@ -1790,7 +1792,8 @@
                 SearchDataTypes sdt = SearchArgs.DataType;
                 //byte[] buffered_mem = new byte[(MemoryRangeSize - MemoryRangeStart)]; // throws OutOfMemoryException if size is over 2G
                 logger.Debug.WriteLine(string.Format("Buffered Memory Size -> 0x{0:x8}", MemoryRangeSize - MemoryRangeStart));
-                new Action<int, string>(UpdateProgress).Invoke(0, string.Format("Search is Warming Up...Please Wait..."));
+                UpdateProgress(0, string.Format("Search is Warming Up...Please Wait..."));
+                //new Action<int, string>(UpdateProgress).Invoke(0, string.Format("Search is Warming Up...Please Wait..."));
                 Stopwatch provider_st = new Stopwatch();
                 provider_st.Start();
                 using (GenericMemoryProvider provider = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
@@ -2441,7 +2444,8 @@
                                                 if (int_percent_done <= 100)
                                                 {
                                                     //Last_Whole_Percent_Done = int_percent_done;
-                                                    new Action<int, string>(UpdateProgress).Invoke(int_percent_done, string.Format(" -> Reading Address: 0x{0:x8}", i + MemoryRangeStart));
+                                                    UpdateProgress(int_percent_done, string.Format(" -> Reading Address: 0x{0:x8}", i + MemoryRangeStart));
+                                                    //new Action<int, string>(UpdateProgress).Invoke(int_percent_done, string.Format(" -> Reading Address: 0x{0:x8}", i + MemoryRangeStart));
                                                 }
                                                 //}
                                                 //this.Refresh();
@@ -2603,7 +2607,8 @@
         private void SearchWorkerThread_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
         {
             try { if ((bool)e.Result) { logger.Warn.WriteLine("Search operation was cancelled."); 
-                new Action<int, string>(UpdateProgress).Invoke(0, string.Empty);
+                //new Action<int, string>(UpdateProgress).Invoke(0, string.Empty);
+            UpdateProgress(0, string.Empty);
                 return; } 
             }
             catch (InvalidCastException) { }
@@ -2616,7 +2621,8 @@
             catch (InvalidCastException) { }
             catch (Exception ex) { throw ex; }
 
-            new Action<int, string>(UpdateProgress).Invoke(100, string.Empty);
+            UpdateProgress(100, String.Empty);
+            //new Action<int, string>(UpdateProgress).Invoke(100, string.Empty);
             bool unsigned = SearchArgs.IsUnsignedDataType;
             using (SearchResultReader reader = new SearchResultReader(SearchGuid))
             {
@@ -2676,7 +2682,8 @@
             btnSearch.Enabled = true;
             grpCompareType.Enabled = true;
             grpCompareValue.Enabled = true;
-            new Action<int, string>(UpdateProgress).Invoke(0, string.Empty);
+            UpdateProgress(0, string.Empty);
+            //new Action<int, string>(UpdateProgress).Invoke(0, string.Empty);
             grpDataType.Enabled = false;
             // resume process on reset, incase it was suspended
             ThreadControl.ResumeProcess(this.AcceptedProcess.Id);
@@ -2728,8 +2735,9 @@
             lstResults.Items.Clear();
 
             if (lstResults.Items.Count > 0) { timer_update_results.Enabled = true; }
-            else { timer_update_results.Enabled = false; }            
-            new Action<int, string>(UpdateProgress).Invoke(0, string.Empty);
+            else { timer_update_results.Enabled = false; }
+            UpdateProgress(0, string.Empty);
+            //new Action<int, string>(UpdateProgress).Invoke(0, string.Empty);
             bool _is_unsigned = chkUnsigned.Checked;
             SearchType search_type = new SearchType();
             SearchDataTypes _data_type = new SearchDataTypes();

 

  ViewVC Help
Powered by ViewVC 1.1.22