locked
application loop hangup RRS feed

  • Question

  • hello every one

    I'm using loop to read data from sql and then make some calculations then save it again to another table but when application loop for 3 or 4 times it's freeze but the job is done but if loop = 10 or more then it is freeze and hangup for long time .

    i need to learn how to make my application working better and never freeze and make application working with any count for loop without freeze .

    i need sample please

    thank you

    Thursday, January 19, 2012 3:26 PM

Answers

  • If you don't want to let it freeze you can use the backgroundworker to do that job. However if it freezes simply because of getting a resultset, then there is mostly something wrong. 

    You can use a bandage to let it not freeze, but better is to solve why it takes such a long time. 

    So why are you looping at all, normally you can get one resultset access it and let it update again at the server side.

     


    Success
    Cor
    • Proposed as answer by Mike Feng Wednesday, January 25, 2012 4:55 PM
    • Marked as answer by Mike Feng Sunday, January 29, 2012 7:43 AM
    Thursday, January 19, 2012 4:34 PM
  • Hello Buddy 

    below is the nice example for starting with backgroundworker

    http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx

     

    Try to understand it and implement into your app.


    Want to add MVP with my name.
    • Proposed as answer by Mike Feng Wednesday, January 25, 2012 4:55 PM
    • Marked as answer by Mike Feng Sunday, January 29, 2012 7:43 AM
    Thursday, January 19, 2012 6:52 PM
  • am facing a problem with maskedtextbox when i'm trying to use the backgroundworker

     

    thanks

    Hi El,

    Thank you for posting on this forum.

    What is the problem?

    Do you get a problem of update that control?

    If so, please refer to this thread: http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/2438273b-0f68-4fbe-bd9c-72f7cd78662a/

    Or this one: http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/ec8c7fa1-8f2a-4a27-aac3-f625e225f300/

    One thread try to directly update a control created by another thread may raise a cross-threading exception, above thread shows how to use invoke method to update it.

    If I misunderstood anything, please feel free to follow up.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Mike Feng Sunday, January 29, 2012 7:43 AM
    Wednesday, January 25, 2012 4:54 PM

All replies

  • If you don't want to let it freeze you can use the backgroundworker to do that job. However if it freezes simply because of getting a resultset, then there is mostly something wrong. 

    You can use a bandage to let it not freeze, but better is to solve why it takes such a long time. 

    So why are you looping at all, normally you can get one resultset access it and let it update again at the server side.

     


    Success
    Cor
    • Proposed as answer by Mike Feng Wednesday, January 25, 2012 4:55 PM
    • Marked as answer by Mike Feng Sunday, January 29, 2012 7:43 AM
    Thursday, January 19, 2012 4:34 PM
  • thank you for your reply

    am already using this application form in server side application not client one and booth of sql and the application at the same server but i need example how to use the backgroundworker tool i never used it before

    and why it is freeze?? let me tell you it is form calculate every thing about all employee's of company for full month then about 500 employee for 30 days that take much time i need to make it with progress bar and not freezing

    i need sample and thank you for your help

     

    Thursday, January 19, 2012 6:32 PM
  • Hello Buddy 

    below is the nice example for starting with backgroundworker

    http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx

     

    Try to understand it and implement into your app.


    Want to add MVP with my name.
    • Proposed as answer by Mike Feng Wednesday, January 25, 2012 4:55 PM
    • Marked as answer by Mike Feng Sunday, January 29, 2012 7:43 AM
    Thursday, January 19, 2012 6:52 PM
  • Be aware that you then cannot simply use the backgroundworker (or any other async).

    You should take care that if a user start using a button or click the close program, there is no work half done and half of the persons is calculated only partially.

    The solution is than to disable all buttons which can hurt. (But often that is the same as getting it in a freeze state)


    Success
    Cor
    Thursday, January 19, 2012 7:20 PM
  • so what should i do that what I'm asking about in main thread
    Thursday, January 19, 2012 7:44 PM
  • am facing a problem with maskedtextbox when i'm trying to use the backgroundworker

     

    thanks

    Friday, January 20, 2012 11:23 PM
  • am facing a problem with maskedtextbox when i'm trying to use the backgroundworker

     

    thanks

    Hi El,

    Thank you for posting on this forum.

    What is the problem?

    Do you get a problem of update that control?

    If so, please refer to this thread: http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/2438273b-0f68-4fbe-bd9c-72f7cd78662a/

    Or this one: http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/ec8c7fa1-8f2a-4a27-aac3-f625e225f300/

    One thread try to directly update a control created by another thread may raise a cross-threading exception, above thread shows how to use invoke method to update it.

    If I misunderstood anything, please feel free to follow up.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Mike Feng Sunday, January 29, 2012 7:43 AM
    Wednesday, January 25, 2012 4:54 PM