![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | drawstring disappears? I have a progressbar that I'm creating text on. I'm doing so via the following inside a function: graphics = progressBar1.CreateGraphics(); progressBar1.Refresh(); graphics.DrawSTring( theString, SystemFonts.DefaultFont, Brushes.Black, new PointF(progressbar1.Location.X, progressbar1.Location.Y)); I invoke this function from a background worker thread every second. My doWork function in my background worker thread is basically the following: while(true) { invokeTheFunctionToUpdateTheProgressBarTextInTheMainGUIThread(); Thread.Sleep(1000); } My problem is while the progress bar creates the text over it, the text seems to disappear and reappear every second. I'm guessing it has something to do with that Thread.Sleep, but does anybody know how I can update my progress bar text without having the text seem to flicker? Thanks. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: drawstring disappears? "Tom" <johnthompson1@xxxxxx> wrote in message news:56D240F6-D7DE-4637-B72A-26975C5C0E44@xxxxxx Quote: >I have a progressbar that I'm creating text on. I'm doing so via the >following inside a function: > > graphics = progressBar1.CreateGraphics(); > > progressBar1.Refresh(); > graphics.DrawSTring( > theString, > SystemFonts.DefaultFont, > Brushes.Black, > new PointF(progressbar1.Location.X, progressbar1.Location.Y)); > > I invoke this function from a background worker thread every second. My > doWork function in my background worker thread is basically the following: > > while(true) > { > invokeTheFunctionToUpdateTheProgressBarTextInTheMainGUIThread(); > Thread.Sleep(1000); > } > > My problem is while the progress bar creates the text over it, the text > seems to disappear and reappear every second. I'm guessing it has > something to do with that Thread.Sleep, but does anybody know how I can > update my progress bar text without having the text seem to flicker? > > Thanks. > sleeping. If I change the sleep time to be 10 seconds (e.g. Thread.Sleep(10000)), then the text will disappear for 10 seconds, reappear for a split second, and repeat that process. |
My System Specs![]() |
| | #3 (permalink) |
| | Re: drawstring disappears? "Tom" <johnthompson1@xxxxxx> wrote in message news:ueBbhXloJHA.2124@xxxxxx Quote: > > "Tom" <johnthompson1@xxxxxx> wrote in message > news:56D240F6-D7DE-4637-B72A-26975C5C0E44@xxxxxx Quote: >>I have a progressbar that I'm creating text on. I'm doing so via the >>following inside a function: >> >> graphics = progressBar1.CreateGraphics(); >> >> progressBar1.Refresh(); >> graphics.DrawSTring( >> theString, >> SystemFonts.DefaultFont, >> Brushes.Black, >> new PointF(progressbar1.Location.X, progressbar1.Location.Y)); >> >> I invoke this function from a background worker thread every second. My >> doWork function in my background worker thread is basically the >> following: >> >> while(true) >> { >> invokeTheFunctionToUpdateTheProgressBarTextInTheMainGUIThread(); >> Thread.Sleep(1000); >> } >> >> My problem is while the progress bar creates the text over it, the text >> seems to disappear and reappear every second. I'm guessing it has >> something to do with that Thread.Sleep, but does anybody know how I can >> update my progress bar text without having the text seem to flicker? >> >> Thanks. >> > This seems to definately be affected by the background worker thread > sleeping. If I change the sleep time to be 10 seconds (e.g. > Thread.Sleep(10000)), then the text will disappear for 10 seconds, > reappear for a split second, and repeat that process. frozen while it's sleeping then that is what's happening. If your UI is still responsive then it may be something else. Could you provide the code for how you start the thread as well as the invokeTheFunctionToUpdateTheProgressBarTextInTheMainGUIThread() function? Andrew Faust |
My System Specs![]() |
| | #4 (permalink) |
| | Re: drawstring disappears? "Andrew Faust" <aef123@xxxxxx> wrote in message news:uSW5POmoJHA.1292@xxxxxx Quote: > > "Tom" <johnthompson1@xxxxxx> wrote in message > news:ueBbhXloJHA.2124@xxxxxx Quote: >> >> "Tom" <johnthompson1@xxxxxx> wrote in message >> news:56D240F6-D7DE-4637-B72A-26975C5C0E44@xxxxxx Quote: >>>I have a progressbar that I'm creating text on. I'm doing so via the >>>following inside a function: >>> >>> graphics = progressBar1.CreateGraphics(); >>> >>> progressBar1.Refresh(); >>> graphics.DrawSTring( >>> theString, >>> SystemFonts.DefaultFont, >>> Brushes.Black, >>> new PointF(progressbar1.Location.X, progressbar1.Location.Y)); >>> >>> I invoke this function from a background worker thread every second. My >>> doWork function in my background worker thread is basically the >>> following: >>> >>> while(true) >>> { >>> invokeTheFunctionToUpdateTheProgressBarTextInTheMainGUIThread(); >>> Thread.Sleep(1000); >>> } >>> >>> My problem is while the progress bar creates the text over it, the text >>> seems to disappear and reappear every second. I'm guessing it has >>> something to do with that Thread.Sleep, but does anybody know how I can >>> update my progress bar text without having the text seem to flicker? >>> >>> Thanks. >>> >> This seems to definately be affected by the background worker thread >> sleeping. If I change the sleep time to be 10 seconds (e.g. >> Thread.Sleep(10000)), then the text will disappear for 10 seconds, >> reappear for a split second, and repeat that process. > Are you sure you're not calling Sleep on the main UI thread? If your UI is > frozen while it's sleeping then that is what's happening. If your UI is > still responsive then it may be something else. Could you provide the code > for how you start the thread as well as the > invokeTheFunctionToUpdateTheProgressBarTextInTheMainGUIThread() function? > > Andrew Faust Thanks for the response, but I was having so much trouble w/ the progress bar I gave up and now I'm just using a status panel. I deleted all of my original code, but I'm pretty sure I was just calling runworkerasync right after initializecomponent, and i'm my dowork method, i would do the invoking. |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Printing. DrawLine/DrawString. C# [WIN] | .NET General | |||
| DVD disappears (somewhat different) | Vista hardware & devices | |||
| Alt-Tab disappears too quick | Vista General | |||
| vpn disappears in Vista | Vista General | |||
| Sidebar disappears | Vista General | |||