Advanced VB.NET Programming - Threads, Events and Delegates (Part 1)
ฝัง
- เผยแพร่เมื่อ 28 พ.ค. 2024
- This is the first of two computer science lessons about threads, events and delegates. In these two lessons, you will learn how to create a multi-threaded racing game in Visual Basic.NET. The application makes use of the .NET Thread class, which allows you to build responsive applications that can run multiple sub programs at the same time. The game employs custom events to signal changes while the application is running, and delegates, otherwise known as type safe method pointers, to safely marshal method calls between threads. By following along and building this application yourself, you’ll come to see that threads, events and delegates are closely related. To get the most out of this video, you should already be familiar with the basics of high level programming. It would also be advantageous to have some familiarity with object oriented programming. You can find the essentials of object oriented programming with VB.NET in a separate series of computer science lessons. If you’re a C# programmer you still find these videos useful because, although there are some differences in language syntax, the fundamental concepts are the same.
Chapters:
00:00 Features of the game
02:00 Animate a shape with a Graphics object
05:04 Random movement
07:45 Start multiple threads
08:54 What is a thread?
11:05 The ThreadStart Delegate
14:49 Finishing touches
You finally upload new video, My teacher~
There's a whole load of C# videos coming soon :)KD
Thank you for your time in putting together these videos. They have helped tremendously! I hope to see more!
Excellent tutorial from an excellent teacher.
You are very kind. Thank you :)KD
Excellent!
Thank you :)KD
thanks for upload the video ,
First 😍
Ta-daaa 🏆 :)KD
how do we start the two threads simultaneously? i find that whichever thread starts first always wins the race.
I don't know how many programmers still use VB, or Win32 for that matter, but this is a neat example. If you're doing C# next, any chance you could or would do it on Linux? I recently setup mono because a program I want to use was written in C#, but I'm thinking of translating it because I'd really like it to be more performant. However, it might be fun to play with it some, see if it has any features I want to copy to my own language that I haven't already done.
As hobbyist taught myself VB in 1991, and before that Basic using Microsoft Basic. Although there are many gaps in my knowledge, as far as desktop applications go, there is almost nothing it is not capable of. I also know C#, and Java, and am still learning, especially .NET, but prefer VB.
@@theview613 Do you also use Linux?
@@anon_y_mousse No! I understand VB is not useful in Linux.
@@theview613 Why would it not be? As long as there is a compiler for it, it should work. And it's not like you're limited to one language, you could learn more or you could do something really fun and implement a compiler for your language of choice.
Hello, in my code the "random" namespace does not exist, it gives an error BC30182: type not found. I use Visual Studio 2022, how can I solve this?
Check the project type you have used. Is it "Windows Forms App (.NET Framework)"? The "(.NET Framework)" part is important to ensure you have all the code libraries you need. :)KD