in

C1 Community

ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

Show progress timer while binding FlexGrid

Last post 05-06-2008 3:25 AM by Wolfgang Knauf. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 04-29-2008 3:04 PM

    Show progress timer while binding FlexGrid

    I have an app that shows the time it takes to execute a search, much like SQL Management Studio, but the app behaves as though the System.Windows.Forms.Timer gets blocked while binding the results to the FlexGrid. The search runs in the background, but I have to return to the UI thread to bind the results. I turned on tracing and am pretty confident the Timer.Tick event never fires while binding the FlexGrid, even if it takes 10 seconds to bind and Timer.Interval == 1000.


    I tried using a System.Timers.Timer to increment the elapsed time on a background thread. This works great, but I have to Invoke back to the UI thread if I am to update the status bar like SQL Management Studio. Each call to Invoke, however, gets blocked just like before. Now, the elapsed seconds jumps up to the correct time, but does not update while databinding.

    Is there anyway to update the UI while databinding a FlexGrid?

    Filed under:
  • 04-30-2008 5:12 AM In reply to

    Re: Show progress timer while binding FlexGrid

    Hi,

    would it help to move the data binding to a background thread? I would suggest
    you set c1FlexGrid.Redraw = false in the main thread (otherwise all UI calls
    from the thread would have to be wrapped with invokes), start the thread, and
    after it's end set Redraw = true.

    This way your timer should work.

    Hope this helps

    Wolfgang
  • 04-30-2008 8:26 AM In reply to

    Re: Show progress timer while binding FlexGrid

    I can try that, but I thought updating the UI from a background thread is "illegal". I guess that doesn't mean "impossible". Looks like I'm going to have to try breaking the law.

  • 05-06-2008 3:25 AM In reply to

    Re: Show progress timer while binding FlexGrid

    Updating the GUI is possible from background threads, but

    -you have to make all UI calls through "Control.Invoke" (a .NET 2.0 background
    worker will do this automatically).
    If you set Redraw = false when beginning to fill the grid, you don't need Invoke
    calls for all UI operations until you finally set Redraw = true once again (this
    must be done through an invoke).
    -there is the danger of deadlocks, if the UI is e.g. working for the background
    thread to finish with a "Thread.Join" statement.

    If you care for these caveats, background threads should be no problem.

    Best regards

    Wolfgang
Page 1 of 1 (4 items)
Contact ComponentOne: 1.800.858.2739 ©1987-2008 ComponentOne LLC All Rights Reserved.