February 2004 - Posts

Getting WinCVS out of flat mode
If you accidentally browse up to the root directory or some other level that is too large for WinCVS to initially deal with and you have the flat mode browser view toggle button of WinCVS on, WinCVS will freeze indefinitely.  If killing it in Task Manager and restarting doesn't fix your problem, you need to hack the registry.
 
Launch regedit (Start -> Run   "regedit") and browse to:
 
        HKEY_CURRENT_USER/Software/WinCvs/wincvs/CVS settings
 
In CVS settings, find the variable  P_DisplayRecursive in the right hand window.  Right-click on P_DisplayRecursive and select Modify from the right-click menu.  in the window that gets displayed, change the Value data set with only two numbers in it from the 01 to 00.  Then click Ok at the bottom of the window, shut down Registry Editor, start up WinCVS again, and you should now have the flat mode button toggled off.
Transactional behavior on DataTables
 
DataTables publish a number of events that are useful for taking action on a data change.  However, sometimes you need to make transactional changes to a table, where the data is not valid until several changes have completed.  The canonical example is transferring money between accounts; observers should not display the account balances until both the credit and debit have completed.  DataTable.BeginLoadData offers a way to suspend notifications, but it only works for changes made through LoadDataRow. 
 
The below test illustrates the problem:
 
  private int _updateCount = 0;
  /// <summary>
  /// Fails, because BeginLoadData only suspends update notifications from LoadDataRow
  /// </summary>
  [Test]
  public void SuspendUpdates()
  {
   DataTable table = new DataTable("Customers");
   table.Columns.Add("ID", typeof(Int32));
   table.Columns.Add("Name", typeof(string));
   table.Rows.Add(new object[] { 1, "Graham" } );
   table.Rows.Add(new object[] { 2, "Smith" } );
   table.RowChanged+=new DataRowChangeEventHandler(table_RowChanged);
   table.Rows[0]["Name"] = "Sargeant";  // got married, so change the name
   Assertion.AssertEquals("Didn't Update", 1, _updateCount);
   table.BeginLoadData();
   table.Rows[0]["Name"] = "Graham-Sargeant";  // moved to Berkeley, have to hypenate
   // this will fail, since we modified the data without using LoadDataRow
   Assertion.AssertEquals("Update shouldn't have fired again", 1, _updateCount);
  }
  
  // Update handler that increments the updateCount
  private void table_RowChanged(object sender, DataRowChangeEventArgs e)
  {
   _updateCount++;
  }

More Posts