Home All Groups Group Topic Archive Search About
Author
18 Oct 2006 7:46 AM
Dave
I have a calendar control that has runs a longish bit of code in the
ValueChanged event.

How do I get the control to repaint before running the code.

At the moment the calendar month view stays active while the code is
running.

Thanks in advance

VS 2005 / C# / CF2

Author
19 Oct 2006 2:55 AM
Bryan Phillips
You can either call Application.DoEvents or execute your code on a
background thread.  I recommend the latter approach.

Bryan Phillips
MCSD, MCDBA, MCSE
Blog:  http://bphillips76.spaces.live.com




Show quote
"Dave" <Em***@email.org> wrote in message
news:uY4#Hmo8GHA.5092@TK2MSFTNGP04.phx.gbl:

> I have a calendar control that has runs a longish bit of code in the
> ValueChanged event.
>
> How do I get the control to repaint before running the code.
>
> At the moment the calendar month view stays active while the code is
> running.
>
> Thanks in advance
>
> VS 2005 / C# / CF2
Author
19 Oct 2006 3:05 AM
Dave Sexton
Hi Dave,

What you require is asynchronous processing.  You'll have to run the time-consuming code in another thread to free the UI thread.
You'll want to start a "background" process and handle an event when the process completes.  You might need to disable (set
Enabled=false) certain UI components before running code on another thread and returning so that while your code is working in the
background your end-users won't be able to change their state.  For instance, while processing the ValueChanged event for the
Calendar, you'll probably want the Calendar to be disabled until the process completes; however, you'll want the entire application
responsive to user interaction, including the painting of the calendar control, which is accomplished by freeing the UI thread and
running the time-consuming code in a background process as I suggested.

Check out the BackgroundWorker class.

BackgroundWorker on MSDN:
http://msdn2.microsoft.com/en-us/library/8xs8549b.as


--
Dave Sexton

Show quote
"Dave" <Em***@email.org> wrote in message news:uY4%23Hmo8GHA.5092@TK2MSFTNGP04.phx.gbl...
>I have a calendar control that has runs a longish bit of code in the ValueChanged event.
>
> How do I get the control to repaint before running the code.
>
> At the moment the calendar month view stays active while the code is running.
>
> Thanks in advance
>
> VS 2005 / C# / CF2
>
Author
19 Oct 2006 3:16 AM
Dave Sexton
Hi Dave,

The link apparently got chopped.  Here's the complete URL:

http://msdn2.microsoft.com/en-us/library/8xs8549b.aspx

--
Dave Sexton

Show quote
"Dave Sexton" <dave@jwa[remove.this]online.com> wrote in message news:ueqj0ty8GHA.4476@TK2MSFTNGP04.phx.gbl...
> Hi Dave,
>
> What you require is asynchronous processing.  You'll have to run the time-consuming code in another thread to free the UI thread.
> You'll want to start a "background" process and handle an event when the process completes.  You might need to disable (set
> Enabled=false) certain UI components before running code on another thread and returning so that while your code is working in the
> background your end-users won't be able to change their state.  For instance, while processing the ValueChanged event for the
> Calendar, you'll probably want the Calendar to be disabled until the process completes; however, you'll want the entire
> application responsive to user interaction, including the painting of the calendar control, which is accomplished by freeing the
> UI thread and running the time-consuming code in a background process as I suggested.
>
> Check out the BackgroundWorker class.
>
> BackgroundWorker on MSDN:
> http://msdn2.microsoft.com/en-us/library/8xs8549b.as
>
>
> --
> Dave Sexton
>
> "Dave" <Em***@email.org> wrote in message news:uY4%23Hmo8GHA.5092@TK2MSFTNGP04.phx.gbl...
>>I have a calendar control that has runs a longish bit of code in the ValueChanged event.
>>
>> How do I get the control to repaint before running the code.
>>
>> At the moment the calendar month view stays active while the code is running.
>>
>> Thanks in advance
>>
>> VS 2005 / C# / CF2
>>
>
>

AddThis Social Bookmark Button