Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
167 views
in Technique[技术] by (71.8m points)

vb.net - Modify a control (winforms) through another thread

I have this code:

Public Class main

    Public Shared classOne As classOne 
    Public Shared classTwo As classTwo

    Public Shared Sub main()

        classOne = new classOne()
        classTwo = new classTwo()

        classTwo.myThread.Start()

        Application.Run(classOne)
    End Sub

End Class

classOne is a simple winforms with a textlabel. I just would like modify the background color of this textlabel from classTwo but there is a problem because classTwo is in an other thread.

I know I must use a delegate and invoke method but i don't know how to do it. Where should I declare the delegate function and where I have to use invoke method please? I have already ridden the MSDN documentation but I failed to apply it...

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...