Click here to Skip to main content
15,919,434 members
Home / Discussions / C#
   

C#

 
GeneralRe: Adding a List to a List with AddRange Pin
Ista14-Aug-06 10:11
Ista14-Aug-06 10:11 
Questionhow to make a mp3 playlist and play the songs [modified] Pin
aeliminate14-Aug-06 3:58
aeliminate14-Aug-06 3:58 
AnswerRe: how to make a mp3 playlist and play the songs Pin
Judah Gabriel Himango14-Aug-06 4:59
sponsorJudah Gabriel Himango14-Aug-06 4:59 
GeneralRe: how to make a mp3 playlist and play the songs Pin
aeliminate14-Aug-06 5:32
aeliminate14-Aug-06 5:32 
GeneralRe: how to make a mp3 playlist and play the songs Pin
Judah Gabriel Himango14-Aug-06 5:42
sponsorJudah Gabriel Himango14-Aug-06 5:42 
QuestionC# compiling doubt Pin
cuser_id14-Aug-06 3:40
cuser_id14-Aug-06 3:40 
AnswerRe: C# compiling doubt Pin
Judah Gabriel Himango14-Aug-06 4:57
sponsorJudah Gabriel Himango14-Aug-06 4:57 
QuestionMultithreading, Timers and flickering ListView Pin
Tomi8714-Aug-06 3:30
Tomi8714-Aug-06 3:30 
Hi,

I have an application which gets info about system (for example running applications, processes, services, CPU info, OS info, ...). I create ProgressBar which will shows CPU usage (using WMI class to get actual usage). Then I create Timer (System.Windows.Forms.Timer) and set tick interval to one second. To get CPU usage and refresh ProgressBar to current usage value results to flicking in ListViews, when user wants to move with ScrollBar. Because of flicking I decided to create special thread for getting CPU usage and ProgressBar refresh to eliminate flicking. I create a new thread in constructor:

<br />
Thread threadRefresh = new Thread(new ThreadStart(Updating));<br />
threadRefresh.Start();<br />


which calls Updating method:

<br />
private void Updating() {<br />
            refreshTimer.Tick += new EventHandler(RefreshCPUUsage);<br />
            refreshTimer.Interval = 1000;<br />
            refreshTimer.Start();<br />
}<br />


Method RefreshCPUUsage finally refresh ProgressBar:

<br />
private void RefreshCPUUsage(Object myObject, EventArgs myEventArgs) {<br />
     manClass = new ManagementClass("Win32_PerfFormattedData_PerfOS_Processor");<br />
     manObjectCollection = manClass.GetInstances();<br />
               <br />
     foreach (ManagementObject CPU in manObjectCollection) {<br />
         progressBarCPU.Value = (int)Convert.ToUInt64(CPU.GetPropertyValue("PercentProcessorTime"));<br />
         progressBarCPU.PerformStep();<br />
         labelCPUPercent.Text = CPU.GetPropertyValue("PercentProcessorTime").ToString() + " %";<br />
     }<br />
}<br />


This solution doesn't work, so I tried to do other based on System.Threading.Timer and Tread pool. In constructor:

<br />
WaitCallback myThreadMethod = new WaitCallback(Updating);<br />
ThreadPool.QueueUserWorkItem(myThreadMethod);<br />


Updating method:

<br />
private void Updating(Object stateInfo) {<br />
    refreshTimer.Interval = 1000;<br />
    refreshTimer.Elapsed += new ElapsedEventHandler(RefreshCPUUsage);<br />
    refreshTimer.Start();<br />
}<br />


This is working but flickering in ListViews remains. I think that special thread for timer and refreshing can dispose flickering but it fails. Probably I'm doing somewhere mistake, but I don't know where. Please help me.
AnswerRe: Multithreading, Timers and flickering ListView Pin
Ista14-Aug-06 3:43
Ista14-Aug-06 3:43 
GeneralRe: Multithreading, Timers and flickering ListView Pin
Tomi8714-Aug-06 8:31
Tomi8714-Aug-06 8:31 
GeneralRe: Multithreading, Timers and flickering ListView Pin
Ista14-Aug-06 9:51
Ista14-Aug-06 9:51 
GeneralRe: Multithreading, Timers and flickering ListView Pin
Tomi8714-Aug-06 23:59
Tomi8714-Aug-06 23:59 
QuestionT namespace is not found Pin
Ista14-Aug-06 3:26
Ista14-Aug-06 3:26 
AnswerRe: T namespace is not found Pin
JoeSharp14-Aug-06 3:40
JoeSharp14-Aug-06 3:40 
GeneralRe: T namespace is not found Pin
Ista14-Aug-06 3:42
Ista14-Aug-06 3:42 
AnswerRe: T namespace is not found Pin
Josh Smith14-Aug-06 3:46
Josh Smith14-Aug-06 3:46 
GeneralRe: T namespace is not found Pin
Ista14-Aug-06 3:56
Ista14-Aug-06 3:56 
AnswerRe: T namespace is not found Pin
Colin Angus Mackay14-Aug-06 4:00
Colin Angus Mackay14-Aug-06 4:00 
Questiondataset computation Pin
Saamir14-Aug-06 2:57
Saamir14-Aug-06 2:57 
QuestionLoaderLock was detected Pin
Johan Russouw14-Aug-06 2:53
Johan Russouw14-Aug-06 2:53 
AnswerRe: LoaderLock was detected Pin
Ista14-Aug-06 4:12
Ista14-Aug-06 4:12 
AnswerRe: LoaderLock was detected Pin
Mike_V14-Aug-06 4:35
Mike_V14-Aug-06 4:35 
Question.DLL VS .EXE in Dot Net Pin
Arun Hegde14-Aug-06 2:50
Arun Hegde14-Aug-06 2:50 
AnswerRe: .DLL VS .EXE in Dot Net Pin
Guffa14-Aug-06 3:00
Guffa14-Aug-06 3:00 
AnswerRe: .DLL VS .EXE in Dot Net Pin
Ista14-Aug-06 3:24
Ista14-Aug-06 3:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.