Click here to Skip to main content
15,918,808 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Working with selected text in 2 different apps. Pin
Dave Kreskowiak29-Aug-07 8:34
mveDave Kreskowiak29-Aug-07 8:34 
GeneralRe: Working with selected text in 2 different apps. Pin
programmerwantabe29-Aug-07 9:37
programmerwantabe29-Aug-07 9:37 
QuestionCross-thread operation not valid: Pin
Cory Kimble29-Aug-07 4:33
Cory Kimble29-Aug-07 4:33 
AnswerRe: Cross-thread operation not valid: Pin
Luc Pattyn29-Aug-07 6:44
sitebuilderLuc Pattyn29-Aug-07 6:44 
GeneralRe: Cross-thread operation not valid: Pin
Cory Kimble29-Aug-07 9:27
Cory Kimble29-Aug-07 9:27 
GeneralRe: Cross-thread operation not valid: Pin
Luc Pattyn29-Aug-07 9:32
sitebuilderLuc Pattyn29-Aug-07 9:32 
GeneralRe: Cross-thread operation not valid: Pin
Cory Kimble29-Aug-07 10:03
Cory Kimble29-Aug-07 10:03 
GeneralRe: Cross-thread operation not valid: Pin
Luc Pattyn29-Aug-07 11:22
sitebuilderLuc Pattyn29-Aug-07 11:22 
Hi,

a thread is not allowed to touch a Control it did not create.
Since normally all controls are in some relation to each other, and the
first Control (your main form) is created by the first, main or "GUI" thread,
only the GUI thread can access each and every one of your controls.

Additional threads are not allowed to touch existing controls, hence they
must use InvokeRequired and Invoke, as in all the examples.

This method is part of a form class, so Me is a Form (hence a Control):
Private Sub SetText(ByVal [text] As String)

      ' InvokeRequired required compares the thread ID of the
      ' calling thread to the thread ID of the creating thread.
      ' If these threads are different, it returns true.
      If Me.textBox1.InvokeRequired Then
          Dim d As New SetTextCallback(AddressOf SetText)
          Me.Invoke(d, New Object() {[text]})
      Else
          Me.textBox1.Text = [text]
      End If
  End Sub


The Invoke applies to the control that needs being accessed, NOT to
some delegate. How would the delegate know where to send the message ?
Only the Control knows its creator, and whether Invoke is Required.

Study the examples !

Luc Pattyn [Forum Guidelines] [My Articles]


this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google


GeneralRe: Cross-thread operation not valid: [modified] Pin
Cory Kimble30-Aug-07 4:08
Cory Kimble30-Aug-07 4:08 
QuestionGet file ext. from database Pin
jds120729-Aug-07 3:46
jds120729-Aug-07 3:46 
AnswerRe: Get file ext. from database Pin
Dave Kreskowiak29-Aug-07 7:49
mveDave Kreskowiak29-Aug-07 7:49 
GeneralRe: Get file ext. from database Pin
jds120729-Aug-07 8:15
jds120729-Aug-07 8:15 
GeneralRe: Get file ext. from database Pin
Dave Kreskowiak29-Aug-07 8:30
mveDave Kreskowiak29-Aug-07 8:30 
Questionhelp Pin
somunu29-Aug-07 1:49
somunu29-Aug-07 1:49 
AnswerRe: help Pin
Christian Graus29-Aug-07 2:04
protectorChristian Graus29-Aug-07 2:04 
QuestionProblem Deploying my Application with Access with the Correct Mappings Pin
Vimalsoft(Pty) Ltd29-Aug-07 0:18
professionalVimalsoft(Pty) Ltd29-Aug-07 0:18 
AnswerRe: Problem Deploying my Application with Access with the Correct Mappings Pin
Dave Kreskowiak29-Aug-07 6:54
mveDave Kreskowiak29-Aug-07 6:54 
GeneralRe: Problem Deploying my Application with Access with the Correct Mappings Pin
Vimalsoft(Pty) Ltd29-Aug-07 20:09
professionalVimalsoft(Pty) Ltd29-Aug-07 20:09 
GeneralRe: Problem Deploying my Application with Access with the Correct Mappings Pin
Dave Kreskowiak30-Aug-07 1:42
mveDave Kreskowiak30-Aug-07 1:42 
GeneralRe: Problem Deploying my Application with Access with the Correct Mappings Pin
Vimalsoft(Pty) Ltd30-Aug-07 3:30
professionalVimalsoft(Pty) Ltd30-Aug-07 3:30 
QuestionCrystal Report crystaldecisions.vsdesigner error Pin
aqui_i28-Aug-07 23:31
aqui_i28-Aug-07 23:31 
QuestionDeleting an element from an array Pin
KOTO-G28-Aug-07 21:38
KOTO-G28-Aug-07 21:38 
AnswerRe: Deleting an element from an array Pin
Csharp™28-Aug-07 22:08
Csharp™28-Aug-07 22:08 
AnswerRe: Deleting an element from an array Pin
Christian Graus29-Aug-07 0:16
protectorChristian Graus29-Aug-07 0:16 
AnswerRe: Deleting an element from an array Pin
SHatchard29-Aug-07 3:59
SHatchard29-Aug-07 3:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.