none
Application freezes on execution

    Question

  • Hi All,

    I have my application all working now and I am very pleased about that, I have a question though, when the programme runs it works and does its thing but the GUI just sits there, it's frozen so you can't move it to another place on screen or use the "Exit" button I have put on the Form which uses this.close to exit the application.

    Is this purely because the program is struggling with the task that its been set that is frozen until completion?

    Is there a way to improve the response of my application?

    Thanks

    Friday, December 24, 2010 12:01 PM

Answers

  • I believe it is because of the task at hand which is consuming all of the CPU resources. So you have some infinite loop going on or you have some desgin issues (more likely). Are you using threads in your application. If not I suggest using it to execute your task so GUI is free of that!

    Happy to Help :)
    • Proposed as answer by Mio_Miao Thursday, December 30, 2010 7:41 AM
    • Marked as answer by Mio_Miao Friday, December 31, 2010 9:49 AM
    Friday, December 24, 2010 12:09 PM
  • Agreeing with the other posters...

    If your background operations are properly designed and it is still causing the UI thread to lag (because, in fact, those operations are being run on the UI thread), then you will want to look at using separate threads.

    Also, if you are able to use the .NET 4 Framework, your life can be made easier using the Task class in the System.Threading.Tasks namespace.

     

    http://msdn.microsoft.com/en-us/library/system.threading.tasks.aspx

    • Proposed as answer by Mio_Miao Thursday, December 30, 2010 7:41 AM
    • Marked as answer by Mio_Miao Friday, December 31, 2010 9:49 AM
    Friday, December 24, 2010 9:31 PM
  • Another simple way is running operation by backgroundworker class

    for detailes, please read

    [How to: Run an Operation in the Background ]

    [BackgroundWorker Class ]

     


    在現實生活中,你和誰在一起的確很重要,甚至能改變你的成長軌跡,決定你的人生成敗。 和什麼樣的人在一起,就會有什麼樣的人生。 和勤奮的人在一起,你不會懶惰; 和積極的人在一起,你不會消沈; 與智者同行,你會不同凡響; 與高人為伍,你能登上巔峰。
    • Proposed as answer by Mio_Miao Thursday, December 30, 2010 7:41 AM
    • Marked as answer by Mio_Miao Friday, December 31, 2010 9:49 AM
    Saturday, December 25, 2010 3:41 AM

All replies

  • Can you please show us the code, which you presure has the issue of freezing?

    The problem is in some infinitive loop, or in some thread, which cannot end.

    But hard to tell by heart, I would like to see the code.

     

    Mitja

    • Edited by Mitja Bonca Friday, December 24, 2010 12:10 PM
    Friday, December 24, 2010 12:06 PM
  • I believe it is because of the task at hand which is consuming all of the CPU resources. So you have some infinite loop going on or you have some desgin issues (more likely). Are you using threads in your application. If not I suggest using it to execute your task so GUI is free of that!

    Happy to Help :)
    • Proposed as answer by Mio_Miao Thursday, December 30, 2010 7:41 AM
    • Marked as answer by Mio_Miao Friday, December 31, 2010 9:49 AM
    Friday, December 24, 2010 12:09 PM
  • Agreeing with the other posters...

    If your background operations are properly designed and it is still causing the UI thread to lag (because, in fact, those operations are being run on the UI thread), then you will want to look at using separate threads.

    Also, if you are able to use the .NET 4 Framework, your life can be made easier using the Task class in the System.Threading.Tasks namespace.

     

    http://msdn.microsoft.com/en-us/library/system.threading.tasks.aspx

    • Proposed as answer by Mio_Miao Thursday, December 30, 2010 7:41 AM
    • Marked as answer by Mio_Miao Friday, December 31, 2010 9:49 AM
    Friday, December 24, 2010 9:31 PM
  • Another simple way is running operation by backgroundworker class

    for detailes, please read

    [How to: Run an Operation in the Background ]

    [BackgroundWorker Class ]

     


    在現實生活中,你和誰在一起的確很重要,甚至能改變你的成長軌跡,決定你的人生成敗。 和什麼樣的人在一起,就會有什麼樣的人生。 和勤奮的人在一起,你不會懶惰; 和積極的人在一起,你不會消沈; 與智者同行,你會不同凡響; 與高人為伍,你能登上巔峰。
    • Proposed as answer by Mio_Miao Thursday, December 30, 2010 7:41 AM
    • Marked as answer by Mio_Miao Friday, December 31, 2010 9:49 AM
    Saturday, December 25, 2010 3:41 AM
  • Hello, thanks for everyone's replies, it seems that using Threads has done the trick, I had knowledge of them but never had need to put them into one of my programmes before this has however helped alot so many thanks for all the advice.
    Thursday, January 06, 2011 12:22 PM