---------------------- ASP. NET + Android + I/O Development S,. Net training, hope to communicate with you! ----------------------
The first computer can only execute one task at a time, but the process takes at least one second. The time here is the process and
Contrast between threads
Early computers used the process concept. Later, the switching between processes was too slow (too slow ).
Because it has a lot of resources)
So thread is introduced.
Processes include threads-it can be said that threads are detailed by processes
At the same time, the operating system can only switch one thread. The thread switching per unit of time is usually around 19 ms.
Over 30 ms
A thread is the minimum unit for Job Scheduling in the Windows operating system. The thread execution is irregular and the operating system has its own
A set of operating mechanisms,
Of course, if there are other threads waiting for a long time, it will automatically adjust the priority between threads
This. Text = thread. currentthread. managedthreadid + ""; get the current working thread
// Allow other threads to access the control created by the current thread: Control
Control. checkforillegalcrossthreadcils = false; // check whether the cross-thread is invalid.
[Thread considerations]
The more threads, the better, because the operating system consumes a lot of resources when creating and destroying threads.
Source and time (creating a thread requires at least 1 MB of memory space)
[Asynchronous delegation implementation is similar to multithreading]
Asynchronous delegation is used by multithreading + delegation to programmers who do not understand multithreading.
[Lock]
Why use the reference type variable lock (p) Here P can be any reference type variable
Because there is a Synchronous Index block in the reference type, such a mechanism is used to implement synchronization between threads and is locked.
Thread Block Code
Any variable or method in it will only allow other threads
To ensure
Resource synchronization when multiple threads access public resources
[Key]
The essence of delegation is a special type that limits the return values and parameter types of the method body at the same level as the class.
The delegate needs to be bound to a method. It is bound to a famous method that has no name.
Lambda expressions
The expression for removing the name of a function (method) is lambda.
Main form
// Defines a delegate
Public Delegate void settextdel (string txt );
Button event of the main form
{
Childfrm FRM = new childfrm ();
FRM. _ settextdel = new settextdel (settext );
}
One Method
Public void settext (string txt)
{
This.txt message. Text = txt;
}
Child form FRM
// Declares a delegate
Public settextdel _ settextdel;
Subform Click Event
_Settextdel(this.txt source. Text );
-------------------- ASP. NET + Android + iOS development,. Net training, and hope to communicate with you! ----------------------
See http://edu.csdn.net for details