Results 1 to 7 of 7

Thread: [RESOLVED] Detect what launches a function...

  1. #1

    Thread Starter
    Hyperactive Member Cyb3rH4Xter's Avatar
    Join Date
    May 2009
    Location
    Sweden
    Posts
    449

    Resolved [RESOLVED] Detect what launches a function...

    I am starting to get really pissed about this problem now...
    I have a function, worker_DoWork used by a backgroundworker. Something is wrong with it though. When it has run to the end it just runs one more time.
    I have stepped the code and what I can see the background worker jumps straight from the closing bracket to the start again...

    I have breakpointed all places that could have started it again but nope they didn't trip. Not even the worker.RunWorkerAsync() which should be the only right way to start it.

    Is there a way to step through ALL the lines that is being executed? There must be a line somewhere that gets executed but I can't find it

  2. #2
    PowerPoster Evil_Giraffe's Avatar
    Join Date
    Aug 2002
    Location
    Suffolk, UK
    Posts
    2,555

    Re: [RESOLVED] Detect what launches a function...

    Is this Resolved?

    If you have a breakpoint at the point it restarts, you will see in the Call Stack window all the function calls all the way back to the entry point of the application. You can double-click on those stack frames to switch the debugging "view" to that frame, and see all the local variables (local to that frame) etc.

  3. #3

    Thread Starter
    Hyperactive Member Cyb3rH4Xter's Avatar
    Join Date
    May 2009
    Location
    Sweden
    Posts
    449

    Re: [RESOLVED] Detect what launches a function...

    Yes and no, it was resolved but the issue showed up again

    Great tip, exactly what I need though I don't know how to use it quite :/
    If I double click a line it opens a page where it says No Source Found.
    Here is a screenshot on the callstack on a breakpoint at the opening bracket of the DoWork the second time it is run:
    http://s246.photobucket.com/albums/g...krmklipp-2.png

    This is how the program misbehaves:

    I start the worker
    The DoWork is run
    The RunWorkerCompleted runs

    Now, if I don't close the program and continue this happens:

    I start the worker
    The DoWork runs
    The DoWork runs again
    The RunWorkercompleted runs
    The RunWorkercompleted runs again

    If I continue even further:

    I start the worker
    The DoWork runs
    The DoWork runs again
    The DoWork runs again!
    The RunWorkercompleted runs
    The RunWorkercompleted runs again
    The RunWorkercompleted runs again!

    And so on, one more time for each thing each time I repeat...weird!
    I have written an own class for managing the backgroundworker, I can write it here if you want. I have breakpointed the only worker.RunWorkerAsync() and it only executes the first time when I want, the rest happens magically....

  4. #4
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Re: [RESOLVED] Detect what launches a function...

    I suspect you're registering an event each time - which means the event gets registered according to the number of times you clicked. Post your code - I'll glance at it. =)
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  5. #5

    Thread Starter
    Hyperactive Member Cyb3rH4Xter's Avatar
    Join Date
    May 2009
    Location
    Sweden
    Posts
    449

    Re: [RESOLVED] Detect what launches a function...

    I wasn't allowed to post 17000 characters so I attached it instead.

    I use the .Start() to start it. It is to the open source project I am working on, http://code.google.com/p/mkv-chapterizer/.

    Some things maybe don't look that good in this code, for example the custom events, I put them there in like 10 minutes yesterday night in a hurry (the problem was before that of course), and so on. Just break down on the part that ****s it up
    Attached Files Attached Files

  6. #6
    PowerPoster Evil_Giraffe's Avatar
    Join Date
    Aug 2002
    Location
    Suffolk, UK
    Posts
    2,555

    Re: [RESOLVED] Detect what launches a function...

    Quote Originally Posted by Lord_Rat View Post
    I suspect you're registering an event each time - which means the event gets registered according to the number of times you clicked. Post your code - I'll glance at it. =)
    LR got it:

    csharp Code:
    1. public void Start()
    2.         {
    3.  
    4.             worker.DoWork += new DoWorkEventHandler(worker_DoWork);
    5.             worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
    6.             worker.WorkerSupportsCancellation = true;
    7.  
    8.             Finished = false;
    9.             worker.RunWorkerAsync();
    10.            
    11.         }

    Move the first three lines to a constructor.

  7. #7

    Thread Starter
    Hyperactive Member Cyb3rH4Xter's Avatar
    Join Date
    May 2009
    Location
    Sweden
    Posts
    449

    Re: [RESOLVED] Detect what launches a function...

    Thank you so much Evil_Giraffe and Lord_Rat!
    Now it works as it should

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width