tag:blogger.com,1999:blog-4252428322984442391.post2731661591054531182..comments2023-05-18T05:57:45.463-07:00Comments on withoutbugs.com: Delegates vs MethodsUnknownnoreply@blogger.comBlogger3125tag:blogger.com,1999:blog-4252428322984442391.post-46341440819775816142012-01-19T01:24:10.692-08:002012-01-19T01:24:10.692-08:00Or... you can turn off `CheckForIllegalCrossThread...Or... you can turn off `CheckForIllegalCrossThreadCalls=False` of your form.Chief Editorhttps://www.blogger.com/profile/17678121382231285858noreply@blogger.comtag:blogger.com,1999:blog-4252428322984442391.post-73091250157802567232012-01-18T10:36:16.141-08:002012-01-18T10:36:16.141-08:00And gosh, after I sit here and think about your co...And gosh, after I sit here and think about your code, I tried...<br /><br /> Private Sub SetText([text] As String)<br /> ' InvokeRequired required compares the thread ID of the<br /> ' calling thread to the thread ID of the creating thread.<br /> ' If these threads are different, it returns true and fires, Else not.<br /> Try<br /> If Me.txt_folderactivity.InvokeRequired Then<br /> Me.txt_folderactivity.Invoke(New SetTextCallback(AddressOf SetText), [text])<br /> Else<br /> Me.txt_folderactivity.AppendText([text])<br /> Me.txt_folderactivity.SelectionStart = txt_folderactivity.Text.Length<br /> Me.txt_folderactivity.ScrollToCaret()<br /> End If<br /> Catch ex As Exception<br /> Me.txt_folderactivity.AppendText(ex.Message & vbCrLf)<br /> End Try<br /> End Sub<br /><br />...and I don't know exactly why it works but it does. So, you helped me by getting me to think about this from a different direction! Thank you!Billnoreply@blogger.comtag:blogger.com,1999:blog-4252428322984442391.post-53999482784948224592012-01-18T10:23:37.238-08:002012-01-18T10:23:37.238-08:00This might be an old post (I can't see a date)...This might be an old post (I can't see a date), but perhaps you can help sort out something.<br /><br />I'm using a delegate to update a TextBox from another thread, but that TextBox is multiline so I have a short sub to scroll it to the bottom whenever I add a line. I'm trying to figure out how to do a Delegate for this as well but I'm stumped. Can you help? Is there a better option?<br /><br /> Private Sub scrollTextDel()<br /> txt_folderactivity.SelectionLength = 0<br /> txt_folderactivity.SelectionStart = txt_folderactivity.Text.Length<br /> txt_folderactivity.ScrollToCaret()<br /> End Sub<br /><br />I know this is VB and your article is C#, but I can translate if I need to. I just need some help getting going.Billnoreply@blogger.com