Multi-Threading!

Discussion in 'Code Snippets and Tutorials' started by Skyle, Apr 20, 2008.

  1. Skyle

    Skyle Level II

    Joined:
    Aug 13, 2007
    Messages:
    212
    Likes Received:
    7
    For some reason, The error "Cross-thread operation not valid: Control 'Status' accessed from a thread other than the thread it was created on." occured.

    I used this coding to apply threading:

    Under CMDStart:
    "ABThread = New System.Threading.Thread(AddressOf MainShop)
    ABThread.IsBackground = True
    ABThread.Start()"

    Under Declarations:

    "Private ABThread As Thread"

    Please can somebody help. This never happened to me before.
     
  2. ricky92

    ricky92 Administrator
    Staff Member

    Joined:
    Nov 10, 2006
    Messages:
    1,866
    Likes Received:
    67
    You're trying to access a control from a thread which is not the one that contains it. To manage them correctly, use delegates (or you could just add "Control.CheckForIllegalCrossThreadCalls = False" in the Form_Load event...).
     
  3. Skyle

    Skyle Level II

    Joined:
    Aug 13, 2007
    Messages:
    212
    Likes Received:
    7
    Thanks but I figured it. I was using Status.text when it was ToolStripStatusBar1.text.

    Hehe...