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. Worker thread problem

Worker thread problem

Scheduled Pinned Locked Moved C#
help
6 Posts 4 Posters 0 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.
  • R Offline
    R Offline
    Rick van Woudenberg
    wrote on last edited by
    #1

    Dear all, In my program, I have written a method to send out an e-mail. However, my entire GUI freezes for a moment until the e-mail has been sent. I would like to create a worker thread that sends the e-mail ( invoke the method from that thread ) so that my main GUI stays alive and functional. I've looked through many examples on the net, but they are all a bit of an overkill. I remember there was an easy way of doing it. Can anyone please point me in the right direction. Cheers, Rick

    M L 2 Replies Last reply
    0
    • R Rick van Woudenberg

      Dear all, In my program, I have written a method to send out an e-mail. However, my entire GUI freezes for a moment until the e-mail has been sent. I would like to create a worker thread that sends the e-mail ( invoke the method from that thread ) so that my main GUI stays alive and functional. I've looked through many examples on the net, but they are all a bit of an overkill. I remember there was an easy way of doing it. Can anyone please point me in the right direction. Cheers, Rick

      M Offline
      M Offline
      Mustafa Ismail Mustafa
      wrote on last edited by
      #2

      Well, generally speaking, multi-threaded applications are not that simple. However, you can use the BackgroundWorker or ThreadPool, those are the easiest to deal with, especially suitable in situations like yours. Check thisout:

      • Clickety[^]

      If you still have issues post back

      "Every time Lotus Notes starts up, somewhere a puppy, a kitten, a lamb, and a baby seal are killed. Lotus Notes is a conspiracy by the forces of Satan to drive us over the brink into madness. The CRC-32 for each file in the installation includes the numbers 666." Gary Wheeler "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Coo

      L 1 Reply Last reply
      0
      • R Rick van Woudenberg

        Dear all, In my program, I have written a method to send out an e-mail. However, my entire GUI freezes for a moment until the e-mail has been sent. I would like to create a worker thread that sends the e-mail ( invoke the method from that thread ) so that my main GUI stays alive and functional. I've looked through many examples on the net, but they are all a bit of an overkill. I remember there was an easy way of doing it. Can anyone please point me in the right direction. Cheers, Rick

        L Offline
        L Offline
        leppie
        wrote on last edited by
        #3

        SmtpClient.SendAsync(), make sure you attach to the SendCompleted event if you want to know it has finished.

        xacc.ide - now with IronScheme support
        IronScheme - 1.0 alpha 1 out now

        1 Reply Last reply
        0
        • M Mustafa Ismail Mustafa

          Well, generally speaking, multi-threaded applications are not that simple. However, you can use the BackgroundWorker or ThreadPool, those are the easiest to deal with, especially suitable in situations like yours. Check thisout:

          • Clickety[^]

          If you still have issues post back

          "Every time Lotus Notes starts up, somewhere a puppy, a kitten, a lamb, and a baby seal are killed. Lotus Notes is a conspiracy by the forces of Satan to drive us over the brink into madness. The CRC-32 for each file in the installation includes the numbers 666." Gary Wheeler "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Coo

          L Offline
          L Offline
          leppie
          wrote on last edited by
          #4

          Mustafa Ismail Mustafa wrote:

          However, you can use the BackgroundWorker or ThreadPool, those are the easiest to deal with, especially suitable in situations like yours.

          Wha??? See my post. I dont understand why people want to revert to monsters!

          xacc.ide - now with IronScheme support
          IronScheme - 1.0 alpha 1 out now

          M P 2 Replies Last reply
          0
          • L leppie

            Mustafa Ismail Mustafa wrote:

            However, you can use the BackgroundWorker or ThreadPool, those are the easiest to deal with, especially suitable in situations like yours.

            Wha??? See my post. I dont understand why people want to revert to monsters!

            xacc.ide - now with IronScheme support
            IronScheme - 1.0 alpha 1 out now

            M Offline
            M Offline
            Mustafa Ismail Mustafa
            wrote on last edited by
            #5

            Hmmm, live and learn. I've never actually had to send an email through C#. Thank you leppie, much obliged :)

            "Every time Lotus Notes starts up, somewhere a puppy, a kitten, a lamb, and a baby seal are killed. Lotus Notes is a conspiracy by the forces of Satan to drive us over the brink into madness. The CRC-32 for each file in the installation includes the numbers 666." Gary Wheeler "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Coo

            1 Reply Last reply
            0
            • L leppie

              Mustafa Ismail Mustafa wrote:

              However, you can use the BackgroundWorker or ThreadPool, those are the easiest to deal with, especially suitable in situations like yours.

              Wha??? See my post. I dont understand why people want to revert to monsters!

              xacc.ide - now with IronScheme support
              IronScheme - 1.0 alpha 1 out now

              P Offline
              P Offline
              Pete OHanlon
              wrote on last edited by
              #6

              leppie wrote:

              I dont understand why people want to revert to monsters!

              OK - I now have an image of Scooby Doo in my head and it's not going away. Thanks for that.

              Deja View - the feeling that you've seen this post before.

              My blog | My articles

              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