If the process of this event takes too long, then you will hold up the message queue and create the "Not responding" message. Some of these events are also clicks on a button and these will execute all the code that you made. If the time between these paint events is too long you see the message "Not responding". You can only see the changes that are made (like showing a progress bar) during these paint events. In the background there is something constantly checking this queue for new events and executing them, one of these events is to draw the screen (paint), basically showing your form on the screen. Everything that you do on that form like moving your mouse, clicking a button, moving/resizing the form, typing and many more is converted to events and placed in this queue. It's not completely clear from the code that you have posted but my guess is that you have this problem because of the way how winforms works with threads and one of the reasons why the async was 'invented'.Ī windows form is based on something like a message queue. Report.PercentageComplete = x //not part of this code but it's a counterįoreach (DirectoryInfo subdir in dirs) Director圜opy(subdir.FullName) String temppath = Path.Combine(sourceDirName, file.Name) Private void Director圜opy(string sourceDirName)ĭirectoryInfo dir = new DirectoryInfo(sourceDirName) ĭirectoryInfo dirs = dir.GetDirectories() įileInfo files = dir.GetFiles("*.mp3") unttot = Directory.GetFiles(Globals.pathdir, "*.mp3", SearchOption.AllDirectories).Length To void flooding with code, just gonna put one function which is not working (ie the progressbar is not even showing up): private void getMp3Files() One difference that i can see if that it works with functions which are async but not with functions which are not async. My issue is that this works for some functions but not all. With ShowtheProgress because I didn't find a way to convert from Progress to IProgress: private void showtheProgress(IProgress progress) Now for each of the functions, I usually start with : report.max = count Progress.ProgressChanged += ReportProgress My declarations are as follow : ProgressReportModel report = new ProgressReportModel() So I have a class report and a Progress progress. I'd like to monitor progress for each of them. I have a progress bar in my main form and a menuStrip with a few maintenance functions on a mysql DB. I'm discovering this and can't get to understand how it works.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |