Parameterized ThreadStart Delegate in C sharp Arabic #87



 Parameterized ThreadStart Delegate in C sharp Arabic #87

Suggested Videos

❑ The purpose of Parameterize dThreadStart delegate.

Use ParameterizedThreadStart delegate to pass data to the thread function



The code in the Main() function can also written as shown below

Here we are not explicitly creating an instance of ParameterizedThreadStart Delegate. Then how is it
working ? It’s working because ,the compiler implicitly convert

When to use ParameterizedThreadStart over ThreadStart delegate?
Use ParameterizedThreadStart delegate if you have some data to pass to the Thread function , otherwise just use ThreadStart delegate.



Please note: Using ParameterizedThreadStart delegate and Thread.Start(Object) Method to pass data to the Thread function is not type safe as they operate on object datatype and any type of data can be passed. If you try change the data type of the target parameter of PrintNumbers() Function from object to int , a compiler error will be raised as the signature of PrintNumbers() function does not match with the signature of ParameterizedThreadStart delegate. Next video: Passing data to be thread function without loosing the type safety.





Follow Us

YouTube

 If you want to download pptx : click Telegram

Facebook

Twitter

Instagram

Tik Tok



إرسال تعليق

أحدث أقدم