 |
|
|
This program is absoulutely awesome, however the in-code documentation is lacking. Good program though.
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
 |
|
|
Hey, great control & idea. A few issue's though, perhaps when the visibility of the control is false, and the timer is active, surely you wouldnt want the ticker too continue repainting.
Also, if the current thread that it is executed on is busy, the control doesnt visually update, any idea's or suggestions on how too work around this?
Drugs are bad, very very bad. Now give them to me for safe keeping 
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
If you look at the original post in the VB.NET section it explains that if you have a process that blocks, or is busy, whatever is running in that thread will block, hence the control stops scrolling. The class below can be used as a class to <[insert here your process]> on another thread. I'm using it for xml serialization. I'm assuming you are using the progressbar as some sort of indicator on a form while you are processing. Start your progressbar, create an instance of this class, modifying it so that it performs your process, and then call the spinup method When it is complete, the LoadComplete property will be set to true. That's how you will know it's done. Make sure you call the SpinDown method when done. That releases the thread. THat's all there is to it...threading's so COOL!
Imports System.Threading Imports System.io Imports System.xml.Serialization Friend Class DocLoaderThread Private _Thread As Thread Private _Document As Document Private _FileName As String Private _IsCancelled As Boolean Private _LoadComplete As Boolean Public ReadOnly Property LoadedDocument() As Document Get Return _Document End Get End Property Public ReadOnly Property LoadComplete() As Boolean Get Return _LoadComplete End Get End Property Private Sub Start() Try Dim xmlser As New XmlSerializer(GetType(Document)) Dim reader As New StreamReader(_FileName) _Document = xmlser.Deserialize(reader) reader.Close() Catch ex As Exception _Document.SetLoadError(ex) Finally Me._LoadComplete = True End Try End Sub Private Sub Cancel() _IsCancelled = True End Sub Public Sub Spinup(ByVal FileName As String) _Document = New Document _FileName = FileName Dim ThreadStart As New ThreadStart(AddressOf Me.Start) _Thread = New Thread(ThreadStart) _Thread.Start() End Sub Public Sub SpinDown() Cancel() _Thread.Join() _Thread = Nothing End Sub End Class
Greg Osborne Microsoft Certified Professional Since 1995
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
|
Can you post your sample code? I use this during object Deserialization which is similar to your task. The progress bar becomes idole during the object deserialization.
Haiyan DU
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I finished this task with the System.ComponentModel.BackgroundWorker You have progressbar which autoprogress set to true and visible set to false. when user start the program, no one will see this progress bar. when user click a button, this progress bar visible is set to true and we call SpineUp() now. here is my code: --------------------- private System.ComponentModel.BackgroundWorker _backThread; public Form1() { InitializeComponent(); _backThread=new System.ComponentModel.BackgroundWorker(); this._backThread.DoWork += new System.ComponentModel.DoWorkEventHandler(this.ProcessNumbersBackgroundWorker_DoWork); this._backThread.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.ProcessNumbersBackgroundWorker_RunWorkerCompleted); } private void ProcessNumbersBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { //Do your work here }
private void ProcessNumbersBackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { this._ProgressBarPanel.Visible=false; MessageBox.Show("Done background work!"); } private void button4_Click(object sender, EventArgs e) { this._ProgressBarPanel.Visible=true; SpineUp(); } private void SpineUp() { _backThread.RunWorkerAsync(); }
Haiyan DU
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Another note...don't be surprised if it still blocks when you are trying to debug it. I have experienced this in the VS-IDE with my current installation, but not with others in the past. It may be a configuration problem on my part. It soes work fine though compiled running outside the ide
Greg Osborne Microsoft Certified Professional Since 1995
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi, This one from that thingy controls everyone can code but lazy to. )
Thanks, as well! Great work.
As always, some notes about flickering: paste this inside InitializeComponent()
this.ResizeRedraw = true; this.SetStyle(ControlStyles.UserPaint, true); this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); this.SetStyle(ControlStyles.DoubleBuffer, true);
Looks better after that.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
I've implemented this code in VB.NET and it works great, but I don't understand why I had to comment out SetStyle(ControlStyles.UserPaint, True), which causes the control to become invisible..? Could it be because I have it subclassed inside a statusbar? Why does it work in C# for you guys?!
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
This has already been implemented in VB Go to here for the code
http://www.codeproject.com/vb/net/NeverEndingBar.asp
Don't know why that makes the bar invisible...I never had that behavior when developing it
Greg Osborne Microsoft Certified Professional Since 1995
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Yeah, I'm using the VB version, but posted the question here because I ported LEXXa's C# flickering solution code to VB in order to resolve some of the flickering issues. I'm just trying to understand why the SetStyle(ControlStyles.UserPaint, True) call didn't fly, but the rest of them did (and reduced the flickering). While the flickering situation has been improved greatly as a result of using LEXXA's code in ProgressStatus.New(), there still is a little bit that is noticeable, and I'm wondering if it can be eliminated completely if I can somehow set UserPaint without the control disappearing. Since I've got my instance of the control subclassed within a StatusBar, perhaps I have to make these calls on the parent StatusBar instead/also?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
You should include a screenshot of what it ACTUALLY looks like. I was dissapointed after I got it running that it looks nothing like the screenshot...
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
It is what it actually looks like. The graphics on the screen shot were from my own implementation of the bar on a status form. I added the graphics to the ends and text boxes and used graphics for the progress. Flash it up any way you want
Greg Osborne Microsoft Certified Professional Since 1995
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
 |
|
|
Thanks, Nice control.
This is certainly outside of normal (probable) usage but I thought I'd pass on a workaround to a problem I ran into when using the osProgress within a container That is itself resized.
To Reproduce: 1.Add a Panel with Dock=Top 2.Add the osProgressBar1 to the Panel 3.Start the application 4.Resize the form back and forth from multiple times.. It's inconsistent but eventually the progress Bar will no longer display the highlighted block (although it is probably working in the background).
To workaround the problem I just added: osProgressBar1.Position = 0 to the Resize event of the Form
Cheers,
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
Thanks...I actually found that one a few minutes ago myself
Greg Osborne Microsoft Certified Professional Since 1995
|
| Sign In·View Thread·PermaLink | 1.50/5 (2 votes) |
|
|
|
 |