This print for content only-size & color not accurate 7" X 9-1/4" / casebound / malloy


// This delegate can point to any method



Download 21,46 Mb.
Pdf ko'rish
bet679/1830
Sana28.09.2021
Hajmi21,46 Mb.
#188411
1   ...   675   676   677   678   679   680   681   682   ...   1830
Bog'liq
[book] [en] Pro C# 2008 and the NET 3.5 Platform Fourth Edition

// This delegate can point to any method,

// taking two integers and returning an integer.

public delegate int BinaryOp(int x, int y);

When the C# compiler processes delegate types, it automatically generates a sealed class deriv-

ing from System.MulticastDelegate. This class (in conjunction with its base class, System.Delegate)

provides the necessary infrastructure for the delegate to hold onto a list of methods to be invoked at

a later time. For example, if you examine the BinaryOp delegate using ildasm.exe, you would find

the class shown in Figure 11-1.

As you can see, the compiler-generated BinaryOp class defines three public methods. Invoke()

is perhaps the core method, as it is used to invoke each method maintained by the delegate type in

a

synchronous manner, meaning the caller must wait for the call to complete before continuing on

its way. Strangely enough, the synchronous Invoke() method need not be called explicitly from your

C# code. As you will see in just a bit, Invoke() is called behind the scenes when you make use of the

appropriate C# syntax.

BeginInvoke() and EndInvoke() provide the ability to call the current method asynchronously

on a separate thread of execution. If you have a background in multithreading, you are aware that

one of the most common reasons developers create secondary threads of execution is to invoke

methods that require time to complete. Although the .NET base class libraries provide an entire

namespace devoted to multithreaded programming (System.Threading), delegates provide this

functionality out of the box.

C H A P T E R   1 1  




Download 21,46 Mb.

Do'stlaringiz bilan baham:
1   ...   675   676   677   678   679   680   681   682   ...   1830




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish