CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1
  1. #1
    Join Date
    Jul 1999
    Location
    Poland
    Posts
    278

    ParentRelations.Add() desn't work from time to time ...

    I have some problem with binding two tables in DataGrid control.

    when I run my code when TEST ( SIMULATE ) is active it works perfect.
    when I switch to real system it doesn't work, the code has deadlock in placed marked as "DeadLock heare"
    my english is poor, so please have a look on my part of code.
    Code:
    public class Form1 : System.Windows.Forms.Form
    {
      ...
    
      private void ShowLogsValue()
      {
         // for Test only, DataTable is loaded with some random data
         if ( SIMULATE_ACTIVE )
         {
           m_threadLoadData = new Thread ( new ThreadStart( oradb.GetLogsORAData_TEST ));
           m_threadLoadData.Name = "LOAD_DATA";
           m_threadLoadData.Start();
           m_threadLoadData.Join(); 
           this.Binde2Tables(); 
           return;
         }
    
        // real process, DataTable is loaded by OdbcDataReader Read() method
        m_threadLoadData = new Thread(new ThreadStart( oradb.GetLogsORAData ));
        m_threadLoadData.Name = "LOAD_DATA";
        m_threadLoadData.Start();
        m_threadLoadData.Join(); 
        this.Binde2Tables(); 
      }
    
      public void Binde2Tables()
      {
        DataRelation myDataRelation;
        DataColumn parentColumn;
        DataColumn childColumn;
        parentColumn = oradb.dsLogsORA.Tables["LogsOracle"].Columns["LogID"];
        childColumn = oradb.dsLogsORA.Tables["LogsOracleData"].Columns["LOGS_ID"];
        myDataRelation = new DataRelation("WartościLogu", parentColumn, childColumn);
        oradb.dsLogsORA.Tables["LogsOracleData"].ParentRelations.Add(myDataRelation);
        m_dGrid1.SetDataBinding(oradb.dsLogsORA,"LogsOracle");
      }
    
    ...
    }
    
    public class OraDB
    {
    
      public void GetLogsORAData()
      {
         while ( myReader.Read() ) 
         {
          ...
         }
        
        DeadLock here 
        myReader.Close();
         ....
      }
    
    
      public void GetLogsORAData_TEST()
      {
        // for Test only, to consume some CPU time
          for(int i = 0; i <= 99999999; i ++)
          {
             test ++;
          }
          ...
       }
     
    }    ....
    Could you please help me with this bug ?

    Thanks in advance

    Andrzej Falk
    Last edited by Andrzej; April 22nd, 2008 at 07:24 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured