Click here to Skip to main content
15,892,805 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Could not load file or assembly or one of its dependencies. Pin
Dave Kreskowiak21-Aug-12 5:08
mveDave Kreskowiak21-Aug-12 5:08 
GeneralRe: Could not load file or assembly or one of its dependencies. Pin
fjdiewornncalwe21-Aug-12 6:25
professionalfjdiewornncalwe21-Aug-12 6:25 
GeneralRe: Could not load file or assembly or one of its dependencies. Pin
Eddy Vluggen21-Aug-12 3:23
professionalEddy Vluggen21-Aug-12 3:23 
GeneralRe: Could not load file or assembly or one of its dependencies. Pin
Karthik Chintala21-Aug-12 3:32
Karthik Chintala21-Aug-12 3:32 
GeneralRe: Could not load file or assembly or one of its dependencies. Pin
Dave Kreskowiak21-Aug-12 3:39
mveDave Kreskowiak21-Aug-12 3:39 
AnswerRe: Could not load file or assembly or one of its dependencies. Pin
Bernhard Hiller21-Aug-12 21:07
Bernhard Hiller21-Aug-12 21:07 
QuestionMessage Removed Pin
20-Aug-12 7:49
professionaljkirkerx20-Aug-12 7:49 
QuestionNot Understanding Delegates (User Error) Pin
Clark Kent12320-Aug-12 4:23
professionalClark Kent12320-Aug-12 4:23 
As the subject states I am having some trouble with implementing a delegate to solve this issue that I am having.

The error that I am receiving is that cross-thread operation is not valid. I have windows form that we will call Form1 for example that has many buttons. For one those buttons opens up another form that we will call for this example Form2 that will display some data. Form2 has a COM obj that is similar to a datagridview, but it displays the data which is similar to a pdf viewer that can allowing zooming and formatting. Before I start posting where my problem is in code I did some searches and everyone suggests to use Delegates to prevent the cross-threading problem. I am quite new to delegates so I have been reading the MSDN Documentation[^] about delegates, but I am still not understanding it quite well. Also, I have read this great article A Beginner's Guide to Delegates[^] about 3 times. I understand it's a introduction article.

Here is snippet of code that is causing me problems while I am using delegates (incorrectly???)
Note: This snippet of code is from Form1
VB
' Create a Delegate to prevent cross-thread exception from occuring
Public Delegate Sub StoreDetailedOutputID(ByVal strID As String)
Private strKey1 As String

Private Sub AnalysisResultsEngineName(ByVal strEngineName As String)
        frmAnalysis_Results_Form.Set_Engine_Name(strEngineName) 'THIS IS WHERE THE CROSS-THREAD ERROR OCCURS
End Sub

Private Sub cmdSpreadSheetOutput_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdSpreadSheetOutput.Click

strKey1 = "Please work!"

' DELEGATE
Dim dEngineName As StoreDetailedOutputID
dEngineName = AddressOf AnalysisResultsEngineName
dEngineName.Invoke(strKey1)

'frmAnalysis_Results_Form.ShowDialog() 'Commented Due to this line of code is never called
End Sub


With that I have a few additional questions so that I may understand what delegates are all about.

-Where should the delegate be created within my program? Form1? Form2?
-Should the Delegates be created on both forms?
-Should I use BeginInvoke instead of Invoke?
-Is Delegates indeed the correct route to go? Should I use Threading?

Any help to clarify my misunderstanding of delegates would be greatly appreciated.
AnswerRe: Not Understanding Delegates (User Error) Pin
Eddy Vluggen20-Aug-12 13:00
professionalEddy Vluggen20-Aug-12 13:00 
GeneralRe: Not Understanding Delegates (User Error) Pin
Clark Kent12321-Aug-12 2:29
professionalClark Kent12321-Aug-12 2:29 
GeneralRe: Not Understanding Delegates (User Error) Pin
Eddy Vluggen21-Aug-12 2:56
professionalEddy Vluggen21-Aug-12 2:56 
GeneralRe: Not Understanding Delegates (User Error) Pin
Clark Kent12321-Aug-12 4:28
professionalClark Kent12321-Aug-12 4:28 
GeneralRe: Not Understanding Delegates (User Error) Pin
Eddy Vluggen21-Aug-12 4:50
professionalEddy Vluggen21-Aug-12 4:50 
QuestionMultiple checkbox in Excel file Pin
oanaa1119-Aug-12 21:20
oanaa1119-Aug-12 21:20 
AnswerRe: Multiple checkbox in Excel file Pin
Sonhospa19-Aug-12 23:37
Sonhospa19-Aug-12 23:37 
AnswerRe: Multiple checkbox in Excel file Pin
Clark Kent12320-Aug-12 3:26
professionalClark Kent12320-Aug-12 3:26 
AnswerStore Keywords in Excel doc Pin
David Mujica20-Aug-12 4:02
David Mujica20-Aug-12 4:02 
AnswerCode snipet Pin
David Mujica20-Aug-12 4:30
David Mujica20-Aug-12 4:30 
GeneralRe: Code snipet Pin
oanaa1120-Aug-12 20:10
oanaa1120-Aug-12 20:10 
QuestionHow to code the next button Pin
garyu8717-Aug-12 22:09
garyu8717-Aug-12 22:09 
AnswerRe: How to code the next button Pin
Eddy Vluggen18-Aug-12 2:05
professionalEddy Vluggen18-Aug-12 2:05 
GeneralRe: How to code the next button Pin
garyu8718-Aug-12 2:38
garyu8718-Aug-12 2:38 
GeneralRe: How to code the next button Pin
Eddy Vluggen18-Aug-12 5:49
professionalEddy Vluggen18-Aug-12 5:49 
GeneralRe: How to code the next button Pin
garyu8718-Aug-12 20:01
garyu8718-Aug-12 20:01 
GeneralRe: How to code the next button Pin
Eddy Vluggen18-Aug-12 23:21
professionalEddy Vluggen18-Aug-12 23:21 

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.