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. thread safe calls

thread safe calls

Scheduled Pinned Locked Moved C#
tutorial
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
    Manu_81
    wrote on last edited by
    #1

    private void HomeFrom_Activated(object sender, System.EventArgs e) { PrimeInfoThread pTh = new PrimeInfoThread(this.pictureBox1,this.panel4,this.button1,this.button3,this.SLabel); Thread t = new Thread(new ThreadStart(pTh.ThreadProc)); t.Start(); //t.Join(); } ... public class PrimeInfoThread { private System.Windows.Forms.PictureBox hPic ; private System.Windows.Forms.Panel hPan ; private System.Windows.Forms.Button but1 ; private System.Windows.Forms.Button but2 ; private System.Windows.Forms.Label slab ; // The constructor public PrimeInfoThread(System.Windows.Forms.PictureBox hP, System.Windows.Forms.Panel hpanel, System.Windows.Forms.Button b1, System.Windows.Forms.Button b2, System.Windows.Forms.Label Sl) { hPic = hP; hPan = hpanel; but1 = b1; but2 = b2; slab = Sl; } public void ThreadProc() { EnumGetEDID InitEnumObj = new EnumGetEDID(); InitEnumObj.AppInitEnum(slab); hPic.Hide(); hPan.Hide(); but1.Show(); but2.Show(); } } I have the above code where I modify my form controls in another thread. Is is safe to do like this. How to do this using thread-safe calls/delegates. Thanks.

    K S 2 Replies Last reply
    0
    • M Manu_81

      private void HomeFrom_Activated(object sender, System.EventArgs e) { PrimeInfoThread pTh = new PrimeInfoThread(this.pictureBox1,this.panel4,this.button1,this.button3,this.SLabel); Thread t = new Thread(new ThreadStart(pTh.ThreadProc)); t.Start(); //t.Join(); } ... public class PrimeInfoThread { private System.Windows.Forms.PictureBox hPic ; private System.Windows.Forms.Panel hPan ; private System.Windows.Forms.Button but1 ; private System.Windows.Forms.Button but2 ; private System.Windows.Forms.Label slab ; // The constructor public PrimeInfoThread(System.Windows.Forms.PictureBox hP, System.Windows.Forms.Panel hpanel, System.Windows.Forms.Button b1, System.Windows.Forms.Button b2, System.Windows.Forms.Label Sl) { hPic = hP; hPan = hpanel; but1 = b1; but2 = b2; slab = Sl; } public void ThreadProc() { EnumGetEDID InitEnumObj = new EnumGetEDID(); InitEnumObj.AppInitEnum(slab); hPic.Hide(); hPan.Hide(); but1.Show(); but2.Show(); } } I have the above code where I modify my form controls in another thread. Is is safe to do like this. How to do this using thread-safe calls/delegates. Thanks.

      K Offline
      K Offline
      kasik
      wrote on last edited by
      #2

      Take a look at this[^] article on BeginInvoke Hope this helps :) Cheers, Will H

      1 Reply Last reply
      0
      • M Manu_81

        private void HomeFrom_Activated(object sender, System.EventArgs e) { PrimeInfoThread pTh = new PrimeInfoThread(this.pictureBox1,this.panel4,this.button1,this.button3,this.SLabel); Thread t = new Thread(new ThreadStart(pTh.ThreadProc)); t.Start(); //t.Join(); } ... public class PrimeInfoThread { private System.Windows.Forms.PictureBox hPic ; private System.Windows.Forms.Panel hPan ; private System.Windows.Forms.Button but1 ; private System.Windows.Forms.Button but2 ; private System.Windows.Forms.Label slab ; // The constructor public PrimeInfoThread(System.Windows.Forms.PictureBox hP, System.Windows.Forms.Panel hpanel, System.Windows.Forms.Button b1, System.Windows.Forms.Button b2, System.Windows.Forms.Label Sl) { hPic = hP; hPan = hpanel; but1 = b1; but2 = b2; slab = Sl; } public void ThreadProc() { EnumGetEDID InitEnumObj = new EnumGetEDID(); InitEnumObj.AppInitEnum(slab); hPic.Hide(); hPan.Hide(); but1.Show(); but2.Show(); } } I have the above code where I modify my form controls in another thread. Is is safe to do like this. How to do this using thread-safe calls/delegates. Thanks.

        S Offline
        S Offline
        Shann
        wrote on last edited by
        #3

        Consider using class Monitor

        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