| Member accessibility member accessibility, 156, 166 MemberInfo
class, 602
type, 599
MemberRef table, 40
MemberwiseClone method, 182
System.Object, 92
memcpy function, 378 memory
addresses, passing between CLR and WinRT, 656
allocating, 506, 507, 513
compacting, in garbage collection, 509, 521
corruption, 506
garbage collection and, 507
inefficient allocation, 676
leaks, 506, 510, 526
limitations of, 506
monitoring, 524
OutOfMemory exception, 510
pressure methods, 539
reclaiming, with garbage collection, 517 MemoryStream
class, 656
object, 614
merging LINQ query results, 720 metadata, 5
assembly, 586
components of, 38
constants and, 175
for conversion operator methods, 197
definition tables in, 39
for events, 604
examining, 431
in human-readable form, 40 identical format of, 152 manifest tables, 47, 49
on properties, 603 property definitions in, 231 reference tables, 39
strings in, 332
tokens, 50
uses for, 5
WinRT, 644, 659
method parameters, passing, 214 MethodDef table, 39
MethodInfo method, 417
objects, converting to RuntimeMethodHandle, 609
methods, 162
accessor, 228, 231, 247, 248 anonymous types and, 240 callback, 249
calling, 102, 103, 163
calling for the first time, 11 calling for the second time, 14 compiling once only, 277 conflict resolution, 170, 171
contract, maintaining when exception thrown, 483
conversion operator, 195 declaring as constants, 224 declaring return types, 223 defined, 24, 152
for encoding classes, 355 for enumerated types, 371 examples of, 163
explicit, and state corruption, 476
explicit interface method implementations (EIMIs), 303, 308, 310
extension, 198, 255
generic, 265, 270, 281, 283, 286
generic and non-generic, 284 instance constructors, 181, 184
interface, calling, 302, 448
invoking after removal from delegate chain, 255
marking as async, 733 nonvirtual vs. virtual, 165 operator overload, 191
out and ref parameters, 282 overloading, arity-based, 286
overrides, 172
overriding, 299
parameters. See parameters parameter types, 214
partial, 204
passing variable number of arguments to, 220
performance issues, 167
polymorphic, 166
Newobj instruction
public, 299
referencing, 35
reliability contract documentation, 496 reliable, 497
return types, 395
splitting specific and generic, 283
static, 106
tables, 301
thread-safe, 759
translating input into events, 256 tuple types and, 241
type constructors, 187
type parameters, defining, 282
virtual, 133, 163, 169
virtual, changing to override, 172 virtual instance, 108
WinRT, 646, 650
MethodWithReturn method, 568
Microsoft Silverlight applications, AppDomains and, 574
Microsoft Spy++, 683
Microsoft SQL Server, AppDomains and, 575 Microsoft Visual Studio, Checked setting, 117 Microsoft Windows NT kernel, 670
migrating code from .NET Framework versions, 459
MinValue field, 317
ModuleDef table, 39, 81
ModuleRef table, 39, 81 modules
building types into, 35 combining into assemblies, 45 in friend assemblies, 156
Monitor class, 476, 794 commonly used methods, 795 example code, 796
passing reference to type object into, 798 problems with, 798
as static class, avoiding, 798 monitoring
AppDomains, 571
memory usage, 524
object lifetimes, 546
MPGO.exe, 21
MSCorEE.dll file, 554
MSCorLib.dll, 35, 558
MSCorWks.dll, 554
MSIExec.exe, 61
MulticastDelegate class, 397
non-public fields, 398
multi-dimensional arrays, 385, 386
multifile assemblies, 46, 48
multiple cores, 677. See also CPUs processing power of, 682 taking advantage of, 682 thread starvation on, 684
UI element removal and, 682 user productivity and, 682
multiple inheritance, 295. See also interfaces multithreaded operating system, 684 MultiWebRequest class, 770
Mutex
class, 780, 785
lock, 792
type, 525
mutexes, 785
N
naked constraints, 288
named parameters, 209, 424
arguments, order of evaluation with, 210 rules and guidelines, 211
NamedPipeServerStream class, 743
namespaces, 97
aliases, creating, 99
assemblies and, 101
creating, 100
WinRT, 645
native C++, 659 native resources
cleanup code for, 534
fixed in number, 538
garbage collection and, 525, 538
wrapping, 530, 532
NetworkStream object, 355
new operator, 92, 506 delete operator and, 93
newline characters, 322
NewLine property, 322
NewMailEventArgs object, 253
newobj instruction, 321
NGen.exe
NGen.exe, 16, 19
intellectual property and, 20 nonstatic events, 152
Normal flag, 546, 547 notifications
for exceptions, 456
for garbage collection, 518, 523
for thread attachment/detachment, 671 unregistering interest in, 260
null
comparing generic type variables with, 291 initializing locally typed variables with, 213 in WinRT, 647
nullable types, 288, 441
boxing, 447
C# support for, 443 calling GetType via, 448
calling interface methods with, 448 CLR support for, 447
null-coalescing operator and, 446 operators and, 444
overloaded operators and, 445 performance and, 445
unboxing, 448
nullable value types, 646
number types, parsing strings into, 348 NumberFormatInfo type, 343 Numbers, vs. enumerated types, 361 NumberStyles parameter, 348
numeric types, 117. See also types recognized formats, 340
NumTimesWordAppearsEquals method, 331
NumTimesWordAppearsIntern method, 332
O
obfuscator utilities, 19
Object class, 296, 362
inheritance, 296
object equality, 139
checking, 140
properties of, 141
object graphs, serializing, 614 serializing multiple, 615
object handles, wrapping, 778
object identity, checking, 140
object lifetime, controlling manually, 545 object-oriented programming (OOP), 160 ObjectDisposedException exception, 534
ObjectHandle type, 595
ObjectInvariant method, 502 objects
allocating and initializing, 106 casting between types, 93 converting between types, 195 corrupted state, avoiding, 228 creating, 92, 106, 596
Equals method, 139
formatting, 344
GetHashCode method, 142
hash codes, 142
initializers, 235
invariants, 498, 501 marshaling by reference, 564 type, 23, 112
OnDeserialization method, 629
OneManyLock class, 802
performance results, 804
OneManyResourceLock class, 804
OnNewMail method, 254 OnThreadException virtual method, 488 op_Addition method, 193
open types, 272
OpenAsync method, 753
OpenExisting methods, 780
operands, generic type variables as, 292 operating system instability, reasons for, 34 OperationCanceledException exception, 652 operations
canceling, 696
canceling after set time, 700 canceling, invoking methods after, 698 cooperative cancellation, 696 preventing cancellation of, 698
operator overload methods, 191 calling internally, 194
CLR handling of, 191
for core numeric types, 193 example of, 192
naming rules, 194
ParseExact method
operators, list of, 193
overloads defined, 152
parameters for, 191
support for, 191
unsupported, 193 operators
binary, 192
checked and unchecked, 116 null-coalescing, 446
and nullable types, 444 unary, 192
op_Explicit method, 197
op_Implicit method, 197
OptimizedAway method, 763
optimizing code, 14, 277, 763 Volatile class and, 765
optional attribute, 212
optional parameters, 209
arguments, order of evaluation with, 210 rules and guidelines, 211
OrderedTaskScheduler, 713 ordinal equality check, 329 out keyword
overloading methods based on, 216 vs. ref keyword, 215
out parameter, 282
OutOfMemory exception, 510 overflows, checked and unchecked, 115 overhead fields, 795
overloading
arity-based, 286 nullable types and, 445
overloading operators. See operator overload methods
override methods, 172
overriding methods, 299
generic, 286
ownership, of thread locks, 791
P
packaging assemblies, 60
Parallel class, 713, 714
performance issues, 714 when to use, 714
Parallel LINQ, 717
buffering and merging, 720 parallel processing queries, 719 partitions across CPU cores, 720 preserving operation order, 718 sequential and parallel queries, 717 stopping queries prematurely, 719
parallel queries, 717
ParallelEnumerable class, 717, 719
ParallelLoopResult instance, 716
ParallelLoopState object, 716
ParallelOptions object, 714
ParamArray attribute, 221
ParamDef table, 39
parameterful properties, 227, 242
accessing from unsupported languages, 247 selecting, 246
ParameterInfo object, 602
parameterless constructors, 186, 235
parameterless properties, 227 parameters
declaring as constants, 224 declaring types, 214, 223
default values, 210, 212 default values, changing, 211 for indexers, 244
named, 209
optional, 209
out keyword vs. ref keyword, 215 params keyword, 221
passing by reference, 215 passing via method, 214 types, in methods, 214 types, interfaces as, 306 validation, 366
variables, 211
weak vs. strong, 223 params keyword, 221
Parse method, 348, 366, 370 exception handling for, 493 overloading, 349
parameters, 349
performance and, 350 skipping leading space, 348
ParseCombiningCharacters method, 333
ParseExact method, 349
Parsing
parsing
dates and times, 349 strings, 348
partial keyword, 159
partial methods, 204
efficiency of, 205 overriding types with, 205 private keyword and, 207 return type for, 207
rules and guidelines, 207 runtime performance and, 206 sealed classes and, 205
in Visual Studio, 206 passing arrays, 382
passing parameters, via reference, 215 path names, loading assemblies with, 586 pbytes local variable, 549
PDB (Program Database) files, 15 PE (portable executable) files
manifest, 47
command-line switches for compiling, 47 components of, 38
embedding resource files into, 53
PE32
(+) files, 6
(+) headers, 38
PE32 headers, 5 platform version and, 9
PerfMon.exe, 524
performance concerns, 15
performance counters, 524 performance issues
binding handles and, 608 context switching and, 672, 673
DLLs and, 672
double-check locking and, 808 exception handling and, 492 execution contexts and, 695 hyperthreading and, 677 instance fields and, 567
I/O operations and, 731
of methods with variable number of arguments, 222
monitoring with Task Manager, 675 Parallel class and, 714
reflection and, 589
tasks and, 708
thread pools and, 692 threads and, 670, 674, 681
thread synchronization and, 758 thread synchronization locks and, 790
Performance Monitor, testing exception handling with, 493
PerfView, 525
periodic compute-bound operations, 720 PEVerify.exe, 18
Pinned flag, 546
pinning objects, 548
points of failure, sources of, 471. See also
exceptions; exception handling policy controls, 86
polygons, arrays of, 375
polymorphism, WinRT components and, 646 pooling strings, 332
positional parameters, 424
PostAsync method, 742
postconditions, 498, 501
execution of, 502
side-effect-free members, 501 Power Threading library, 804 preamble, 353
preconditions, 498, 501
inheritance of, 502
side-effect-free members, 501 preemptive multithreaded operating
system, 684
PrepareConstrainedRegions method, 496
primary constraints, 287
primitive thread sychronization constructs, 760 kernel-mode, 761, 778, 784
interlocked, 768
user-mode, 762
volatile, 766
primitive types, 111
checked and unchecked, 115 comparing to each other, 292 defining constants with, 175 dynamic, 144
as enumerated types, 363 vs. FCL types, 113
with FCL types, 112 parameter default values, 211
Date: 2016-03-03; view: 767
|