As I get further into .NET I feel I need to get a handle more and more on how a computer actually runs. Today as I was reading I came across and attribute of the @Page directive: AspCompat. The definitions I came across kept mentioning threads and processes.
AspCompat is an aid in migrating ASP pages to ASPX pages. It defaults to false but should be set to true in any ASPX file that creates apartment-threaded COM objects–that is, COM objects registered ThreadingModel=Apartment. That includes all COM objects written with Visual Basic 6.0. AspCompat should also be set to true (regardless of threading model)
Courtesy of: .net Funda
- Processes are instances of programs (applications).
- Each process is allocated its own space in the memory and therefore there needs to be an additional step to communicate between processes (using pipes, and so forth).
- Because each process runs in its own space in the memory, there is little chance of overwriting or corrupting data in process A from process B
- Threads are components of a process.
- Threads share memory and the various other system resources, this allows for easy communication between threads.
- Not secure, a thread can write memory used by another thread.
When you have a single processor and you decide to open up Chrome it begins a new process with a new thread. If while you are browsing in Chrome you open up iTunes another process and thread are created. When using a computer with a single processor such as the Pentium series the processes would appear to be working at the same time but in reality they would be alternating sending bits of info. With computer that are running with two or four processors, this would allow each processor to run its own program; one would run Chrome and one would run iTunes.
Multithreading is when you create a thread to run a command/task. The reason for doing this is that when you program using a single thread there may come a time when you require a large amount of information from an external source, such as a database or a server. When this happens it makes more sense to create a new thread and have that retrieve the information in the background. It allows the main application to continue running rather than pausing and waiting for the response from the external source.
Multithreading is something that I doubt I will run across anytime in the close future, but it is important to know how something works. For me learning has always been about researching the things people take for granted when learning a new language or program, such as the AspCompat attribute. Threading will also most likely come into play while I am learning C++ as well this semester.