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 safety with windows form

Threading safety with windows form

Scheduled Pinned Locked Moved C#
tutorialquestion
3 Posts 3 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.
  • M Offline
    M Offline
    mitreviper
    wrote on last edited by
    #1

    Hi all, I read some books that manipulating the window form components using a thread other than a main thread can cause bugs that are not repeatable. Is there any example code of how to get around this ? And next, the documentation in MSDN often have the following statement. Its confusing for me. So when is a member public static and when is it an instance member? :confused: Thread Safety Any public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Any instance members are not guaranteed to be thread safe

    A S 2 Replies Last reply
    0
    • M mitreviper

      Hi all, I read some books that manipulating the window form components using a thread other than a main thread can cause bugs that are not repeatable. Is there any example code of how to get around this ? And next, the documentation in MSDN often have the following statement. Its confusing for me. So when is a member public static and when is it an instance member? :confused: Thread Safety Any public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Any instance members are not guaranteed to be thread safe

      A Offline
      A Offline
      Alex Korchemniy
      wrote on last edited by
      #2

      You can use the Invoke method of the Control class to safely call a piece of code that does a UI task. There's a lot of other things to learn about thread safety. Have fun

      1 Reply Last reply
      0
      • M mitreviper

        Hi all, I read some books that manipulating the window form components using a thread other than a main thread can cause bugs that are not repeatable. Is there any example code of how to get around this ? And next, the documentation in MSDN often have the following statement. Its confusing for me. So when is a member public static and when is it an instance member? :confused: Thread Safety Any public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Any instance members are not guaranteed to be thread safe

        S Offline
        S Offline
        Stefan Troschuetz
        wrote on last edited by
        #3

        A member is public static when it is declared public static and therefor can be accessed without an instance of the class. An instance member on the other side can only be accessed by using an object of the class. A short example:

        public class Test
        {
        // No instance needed to access this member
        public static int StaticMember;
        // Need an instance to access this member
        public int InstanceMember;
        }

        Test.StaticMember = 5;
        Test obj = new Test;
        obj.InstanceMember = 5;


        www.troschuetz.de

        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