Progress bar not updating
Hello all Yes I know its been done before, but something silly is killing me on this. I have simplified my code below(and also built and tested this code). I have the standard progress bar and worker thread scenario with progress of the worker thread being fed back to the main UI and displayed on the progress bar. Basic form1 with progress bar and button nothing else. Hello All, I'm still on the long journey trying to convert a simple Inventor macro to an Inventor Addin. Do Events() Next o Occ When the Addin runs the progress bar does not update until AFTER everything has completed. I actually learned a solution for updating it while working on Android Applications.Its been a painful learning experience and my code is now much, much longer than was in the original ivb. Do Events() would be my usual rescue in such situations, but here it seems to have no effect. In Android apps the recommend way is doing long running tasks in a separate task or thread from the UI.When I set a breakpoint inside the method I can see that the method is called but the progress bar is not moving. UI updates in i OS only take place when your code returns and visits the event loop.Inside the loop I'm sending the message with the new value about several hundert times - but no change at the progress bar at all, only NSLog with correct values. If you have a loop that does a time-consuming task on the main thread and does not return until it's done, your code to update the progress indicator never gets a chance to update the UI.In my macro I used a shaded label, just changing the width to represent the progress, however I've been tempted to use the progress bar for my Addin but it does work as expected as it doesnt update until the Addin has finished running. If there's a long running process it must complete before the controls will repaint themselves.It's not stopping my Addin from working, but just a bit annoying... Display Name'rename the sheet to the Inventor part name If o3DSP = True Then Export3DSketch Points(o Part Doc) 'extract the 3DSketch Points and write to the SHEET If o3DWP = True Then Export3DWork Points(o Part Doc) 'extract the 3DSketch Points and write to the SHEET End If My Prog Bar. So though the progress bar is updating it's not visually apparent.
I have a progressbar which receives the amount of Sub directorys within a main directory as a Maximum value and when i run the program It goes through the directorys to grab all the files within the subdirectory.The percentage calculations seems to work fine and give me 25,50,75,100% correctly only the bar does not seem to "update" the display properly. Click Dim folder Count As Integer = 0 Dim file Count As Integer = 0 If (Msg Box("Please confirm the following actions have been taken before proceeding." & vb New Line & "- Main Directory has been chosen." & vb New Line & "- Folders have been found." & vb New Line & "- Files have been found. For Each Sub Dir As _Folder In l Sub Dirs Dim new Client As New _Client ' 'This returns the total number of sub directorys found in the users selected folder. Text = folder Count & " / " & new Settings.return Sub Dir Count() & " Sub-Directorys Processed." 'Increment Folder Counter. Text = "Status : Currently Processing Folder : " & Sub Folder Name() mod List Debug("Currently Processing Folder : " & Sub Folder Name()) Dim dir Info As New Directory Info(Sub Dir.return Dir Full Path()) Dim files In Dir As File Info() = dir Info.Private Sub btn Start FP_Click(By Val sender As System. " & vb New Line & "If all these are correct, Please continue to process", Msg Box Style. 'THIS WORKS FINE AND DISPLAYS THE CURRENT NUMBER OF FOLDER BEING PROCESSED. folder Count = folder Count 1 'Calculate the percentage. Get Files() For Each dir File In files In Dir If (new File. Extension, new Settings.return Extensions()) = False) Then new Bad File(dir File. To String) new Num Rows(new Reader.return Num Lines(dir File. Do Events() 'Increment File For Each cur Client As _Client In l Clients mod List Debug("Current People in Client List - " & cur Client.return Client Name()) mod List Debug(cur Client.return Client Name & " Has " & cur Client.return Num Of Files()) Next End If Next l Clients.Everything is working great, the bar shows the progress in blue and I get the NSLog output with value.
With this progress bar I want the visualize the processing that I do in a loop that runs in a different class (processing.m), to send the message with the progress to the Main View Controller I'm using a protocol: When I call the set Progress method by sending a message through the protocol I only get the NSLog output with correct value but the progress bar is not moving according to the value!?
On the test directory which has 4 sub directorys I get a maxvalue of 4 and the min value is set to 0 The code above returns the value of 25.0 when entering the first folder which is correct (25% of 4 is 1), But the progressbar does not fill 25% of bar once this folder is processed. Of course Folder Count would be set by you as you are doing now, but this is simply a demo. NET Windows forms solutions Entity Framework in Windows forms C# Get default SQL-Server name instance and create database and tables Sending SMTP email using project configuration file special section for settings Unit testing sending emails Find duplicate records via SQL or LINQ in database table C# Entity Framework 6 unit testing with mocked data and auto cleanup of data 2014-Current Many Thanks for the reply I tried to do that suggestion and it seemed to work properly, But i think im missing something somewhere in my original code but i cant see it for the life of me...