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. Threading

Threading

Scheduled Pinned Locked Moved C#
question
6 Posts 6 Posters 2 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.
  • W Offline
    W Offline
    Wogboiii
    wrote on last edited by
    #1

    Can you use threading without a static method?

    L L T 3 Replies Last reply
    0
    • W Wogboiii

      Can you use threading without a static method?

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, the Main() method of an app has to be static, that is where the app starts. Apart from that, no method has to be static. I typically create a "Job" class that holds the job's parameters and then creates a thread and runs it, nothing static in there. :)

      Luc Pattyn [Forum Guidelines] [My Articles]


      DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.


      1 Reply Last reply
      0
      • W Wogboiii

        Can you use threading without a static method?

        L Offline
        L Offline
        led mike
        wrote on last edited by
        #3

        Wogboiii wrote:

        Can you use threading without a static method?

        I don't see any static methods other than main in the example code in the documentation for BackgroundWorker[^], do you?

        D 1 Reply Last reply
        0
        • W Wogboiii

          Can you use threading without a static method?

          T Offline
          T Offline
          Thomas Weller 0
          wrote on last edited by
          #4

          Sure... The static keyword has nothing to do with how the code is executed, but only with where it lives (instance or type). Static/not static is simply irrelevant when it comes to different threads. In the end, it's all bytes that run through the processor, no matter where they come from... Regards Thomas

          www.thomas-weller.de 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.
          Programmer - an organism that turns coffee into software.

          P 1 Reply Last reply
          0
          • L led mike

            Wogboiii wrote:

            Can you use threading without a static method?

            I don't see any static methods other than main in the example code in the documentation for BackgroundWorker[^], do you?

            D Offline
            D Offline
            DaveyM69
            wrote on last edited by
            #5

            Or in the BGW's code[^].

            Dave
            BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
            Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
            Why are you using VB6? Do you hate yourself? (Christian Graus)

            1 Reply Last reply
            0
            • T Thomas Weller 0

              Sure... The static keyword has nothing to do with how the code is executed, but only with where it lives (instance or type). Static/not static is simply irrelevant when it comes to different threads. In the end, it's all bytes that run through the processor, no matter where they come from... Regards Thomas

              www.thomas-weller.de 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.
              Programmer - an organism that turns coffee into software.

              P Offline
              P Offline
              Paulo Zemek
              wrote on last edited by
              #6

              I think the original poster saw an example using a static method to start a new thread and thought it was a requisite.

              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