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. Web Development
  3. ASP.NET
  4. Static Method to get Data from DB?

Static Method to get Data from DB?

Scheduled Pinned Locked Moved ASP.NET
questiondatabase
3 Posts 2 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.
  • E Offline
    E Offline
    error1408
    wrote on last edited by
    #1

    Hi, if i make a static method, that gets Data from my DB, will the method be threadsafe? I mean while one user requests some data and the method is running, can another user that wants to do the same, read/write the variables in this static method? I know it's a beginners question, i searched a lot but i didn't find an answer. Thanks for helping me in advance.

    G 1 Reply Last reply
    0
    • E error1408

      Hi, if i make a static method, that gets Data from my DB, will the method be threadsafe? I mean while one user requests some data and the method is running, can another user that wants to do the same, read/write the variables in this static method? I know it's a beginners question, i searched a lot but i didn't find an answer. Thanks for helping me in advance.

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      Variables declared locally in a static method are thread safe. Static variables declared in a class or structure are not thread safe.

      --- single minded; short sighted; long gone;

      E 1 Reply Last reply
      0
      • G Guffa

        Variables declared locally in a static method are thread safe. Static variables declared in a class or structure are not thread safe.

        --- single minded; short sighted; long gone;

        E Offline
        E Offline
        error1408
        wrote on last edited by
        #3

        Thank you very much!:-D

        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