Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. multithreading is the problem again.

multithreading is the problem again.

Scheduled Pinned Locked Moved C#
helpquestion
19 Posts 6 Posters 21 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Mystic_

    now let me state the problem again. problem is this that i used multithreading to remove this short comming from my program, that it halts when in execution. even with multiple threads its halt when executing. that is it dont respond to gui interaction. its GUI freezes. i used ThreadPool too but that wont solve my problem either.

    A Offline
    A Offline
    Alexander Wiseman
    wrote on last edited by
    #9

    I would put some tracing in a few of those functions to try and narrow down the bottle-neck. For instance, put a System.Diagnostics.Trace.WriteLine call before and after you spawn the new thread. Also put in a trace inside each thread function, at the beginning and at the end. Run the program in debug mode and check the output. It would be particularly helpful to know if your main thread is getting stuck on Thread.Start or on some subsequent function. Sincerely, Alexander Wiseman

    M 1 Reply Last reply
    0
    • A Alexander Wiseman

      I would put some tracing in a few of those functions to try and narrow down the bottle-neck. For instance, put a System.Diagnostics.Trace.WriteLine call before and after you spawn the new thread. Also put in a trace inside each thread function, at the beginning and at the end. Run the program in debug mode and check the output. It would be particularly helpful to know if your main thread is getting stuck on Thread.Start or on some subsequent function. Sincerely, Alexander Wiseman

      M Offline
      M Offline
      Mystic_
      wrote on last edited by
      #10

      i will try that one out. thanx

      A 1 Reply Last reply
      0
      • M Mystic_

        i will try that one out. thanx

        A Offline
        A Offline
        Alexander Wiseman
        wrote on last edited by
        #11

        If you want, you can post the trace output on the forum here and I'll see if I can help. Sincerely, Alexander Wiseman

        M 1 Reply Last reply
        0
        • A Alexander Wiseman

          If you want, you can post the trace output on the forum here and I'll see if I can help. Sincerely, Alexander Wiseman

          M Offline
          M Offline
          Mystic_
          wrote on last edited by
          #12

          my application is GUI based so where does Trace write its messages. how can i find them?

          A 1 Reply Last reply
          0
          • M Mystic_

            my application is GUI based so where does Trace write its messages. how can i find them?

            A Offline
            A Offline
            Alexander Wiseman
            wrote on last edited by
            #13

            There are two ways to see the output: First, the quick and easy way: 1) If you're using Visual Studio, then run the program in debug mode by pressing F5. When the program exits, you can see all of the trace output in the "Output" window - the same window in which you see the results of the last Build command. In VS 2003 (and I think it is probably in 2002 as well), there is a drop-down box which allows you to select what kind of output you wish to view. After running the program in debug mode, my VS window shows two options "Build" and "Debug". If you set it on "Debug", you should see the trace output. Second, the way which takes a little bit longer, but results are more permanent: 2) Setup a TextWriterTraceListener which will automatically write trace output to a file. Here's how: first, you'll need to make sure you reference the System.Diagnostics namespace in your main form file:

            using System.Diagnostics;

            Second, put a variable in your main form code:

            private TextWriterTraceListener myListener;

            Now, put the following code into your application's main form constructor, or Load event handler:

            myListener = new TextWriterTraceListener("logFile.txt");
            Trace.Listeners.Add(myListener);

            And you're done! Run the program and then look at the file "logFile.txt" for the output. Hope that helps! Let me know what you find. Sincerely, Alexander Wiseman

            M 2 Replies Last reply
            0
            • A Alexander Wiseman

              There are two ways to see the output: First, the quick and easy way: 1) If you're using Visual Studio, then run the program in debug mode by pressing F5. When the program exits, you can see all of the trace output in the "Output" window - the same window in which you see the results of the last Build command. In VS 2003 (and I think it is probably in 2002 as well), there is a drop-down box which allows you to select what kind of output you wish to view. After running the program in debug mode, my VS window shows two options "Build" and "Debug". If you set it on "Debug", you should see the trace output. Second, the way which takes a little bit longer, but results are more permanent: 2) Setup a TextWriterTraceListener which will automatically write trace output to a file. Here's how: first, you'll need to make sure you reference the System.Diagnostics namespace in your main form file:

              using System.Diagnostics;

              Second, put a variable in your main form code:

              private TextWriterTraceListener myListener;

              Now, put the following code into your application's main form constructor, or Load event handler:

              myListener = new TextWriterTraceListener("logFile.txt");
              Trace.Listeners.Add(myListener);

              And you're done! Run the program and then look at the file "logFile.txt" for the output. Hope that helps! Let me know what you find. Sincerely, Alexander Wiseman

              M Offline
              M Offline
              Mystic_
              wrote on last edited by
              #14

              its in the start of web interaction its in the end of Web interaction its in the start of text extract its in the end of text extract 'Testing.exe': Loaded 'c:\windows\assembly\gac\microsoft.mshtml\7.0.3300.0__b03f5f7f11d50a3a\microsoft.mshtml.dll', No symbols loaded. The thread '' (0xc9c) has exited with code 0 (0x0). 'Testing.exe': Loaded 'c:\windows\assembly\gac\custommarshalers\1.0.5000.0__b03f5f7f11d50a3a\custommarshalers.dll', No symbols loaded. The thread '' (0xf78) has exited with code 0 (0x0).

              1 Reply Last reply
              0
              • A Alexander Wiseman

                There are two ways to see the output: First, the quick and easy way: 1) If you're using Visual Studio, then run the program in debug mode by pressing F5. When the program exits, you can see all of the trace output in the "Output" window - the same window in which you see the results of the last Build command. In VS 2003 (and I think it is probably in 2002 as well), there is a drop-down box which allows you to select what kind of output you wish to view. After running the program in debug mode, my VS window shows two options "Build" and "Debug". If you set it on "Debug", you should see the trace output. Second, the way which takes a little bit longer, but results are more permanent: 2) Setup a TextWriterTraceListener which will automatically write trace output to a file. Here's how: first, you'll need to make sure you reference the System.Diagnostics namespace in your main form file:

                using System.Diagnostics;

                Second, put a variable in your main form code:

                private TextWriterTraceListener myListener;

                Now, put the following code into your application's main form constructor, or Load event handler:

                myListener = new TextWriterTraceListener("logFile.txt");
                Trace.Listeners.Add(myListener);

                And you're done! Run the program and then look at the file "logFile.txt" for the output. Hope that helps! Let me know what you find. Sincerely, Alexander Wiseman

                M Offline
                M Offline
                Mystic_
                wrote on last edited by
                #15

                i read it and both the threads which should start r getting started. but GUI still freezes while these two threads execute.

                A 1 Reply Last reply
                0
                • M Mystic_

                  i read it and both the threads which should start r getting started. but GUI still freezes while these two threads execute.

                  A Offline
                  A Offline
                  Alexander Wiseman
                  wrote on last edited by
                  #16

                  Did you put a trace command after the new Thread(new ThreadStart(...)) line in the main code? If not, try that first. If so, did it get output? That is an important point because it will determine whether your main application is getting stuck on the creation of the thread, or on a subsequent call. Sincerely, Alexander Wiseman

                  M 1 Reply Last reply
                  0
                  • A Alexander Wiseman

                    Did you put a trace command after the new Thread(new ThreadStart(...)) line in the main code? If not, try that first. If so, did it get output? That is an important point because it will determine whether your main application is getting stuck on the creation of the thread, or on a subsequent call. Sincerely, Alexander Wiseman

                    M Offline
                    M Offline
                    Mystic_
                    wrote on last edited by
                    #17

                    its in the start of web interaction its in the end of Web interaction its in the start of text extract its in the end of text extract 'Testing.exe': Loaded 'c:\windows\assembly\gac\microsoft.mshtml\7.0.3300.0__b03f5f7f11d50a3a\microsoft.mshtml.dll', No symbols loaded. The thread '' (0xc9c) has exited with code 0 (0x0). 'Testing.exe': Loaded 'c:\windows\assembly\gac\custommarshalers\1.0.5000.0__b03f5f7f11d50a3a\custommarshalers.dll', No symbols loaded. The thread '' (0xf78) has exited with code 0 (0x0). The four starting lines r produced by Trace. "its in the start of web interaction" was written before one .Start() method and the "its in the end of Web interaction" is used after .Start() method and same applies to the 2 lines below that. they r giving output

                    A 1 Reply Last reply
                    0
                    • M Mystic_

                      its in the start of web interaction its in the end of Web interaction its in the start of text extract its in the end of text extract 'Testing.exe': Loaded 'c:\windows\assembly\gac\microsoft.mshtml\7.0.3300.0__b03f5f7f11d50a3a\microsoft.mshtml.dll', No symbols loaded. The thread '' (0xc9c) has exited with code 0 (0x0). 'Testing.exe': Loaded 'c:\windows\assembly\gac\custommarshalers\1.0.5000.0__b03f5f7f11d50a3a\custommarshalers.dll', No symbols loaded. The thread '' (0xf78) has exited with code 0 (0x0). The four starting lines r produced by Trace. "its in the start of web interaction" was written before one .Start() method and the "its in the end of Web interaction" is used after .Start() method and same applies to the 2 lines below that. they r giving output

                      A Offline
                      A Offline
                      Alexander Wiseman
                      wrote on last edited by
                      #18

                      It seems to me that you are actually getting the trace output after you call Thread.Start and before the generated thread finishes. This suggests that your thread starting code isn't a problem at all, but perhaps something that your main code is doing after it starts the threads is causing the GUI to lock up. I would look closely at the code which gets executed on your main thread after you start the worker threads (I don't think you posted that code on the boards).

                      Sincerely, Alexander Wiseman

                      M 1 Reply Last reply
                      0
                      • A Alexander Wiseman

                        It seems to me that you are actually getting the trace output after you call Thread.Start and before the generated thread finishes. This suggests that your thread starting code isn't a problem at all, but perhaps something that your main code is doing after it starts the threads is causing the GUI to lock up. I would look closely at the code which gets executed on your main thread after you start the worker threads (I don't think you posted that code on the boards).

                        Sincerely, Alexander Wiseman

                        M Offline
                        M Offline
                        Mystic_
                        wrote on last edited by
                        #19

                        its all the main() had. main function has only this static void Main() { Application.Run(new Form1()); } as i said reall execution, that is bussiness logic, when i click the button. so all the code in private void bt_load_Click(object sender, System.EventArgs e) { } its getting more and more tricky. isnt it??

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups