Click here to Skip to main content
16,005,121 members
Home / Discussions / C#
   

C#

 
GeneralRe: Continued Values Collection/List/Dictionary Pin
Som Shekhar17-Dec-09 2:40
Som Shekhar17-Dec-09 2:40 
GeneralRe: Continued Values Collection/List/Dictionary Pin
Eddy Vluggen17-Dec-09 9:34
professionalEddy Vluggen17-Dec-09 9:34 
GeneralRe: Continued Values Collection/List/Dictionary Pin
Som Shekhar17-Dec-09 10:12
Som Shekhar17-Dec-09 10:12 
GeneralRe: Continued Values Collection/List/Dictionary Pin
Eddy Vluggen17-Dec-09 13:13
professionalEddy Vluggen17-Dec-09 13:13 
GeneralRe: Continued Values Collection/List/Dictionary Pin
Som Shekhar18-Dec-09 18:59
Som Shekhar18-Dec-09 18:59 
GeneralRe: Continued Values Collection/List/Dictionary Pin
Eddy Vluggen19-Dec-09 0:48
professionalEddy Vluggen19-Dec-09 0:48 
GeneralRe: Continued Values Collection/List/Dictionary Pin
Som Shekhar19-Dec-09 2:28
Som Shekhar19-Dec-09 2:28 
GeneralRe: Continued Values Collection/List/Dictionary Pin
Eddy Vluggen19-Dec-09 9:41
professionalEddy Vluggen19-Dec-09 9:41 
Som Shekhar wrote:
Am I missing something?


The perversion to launch a new thread from a Visual Basic 6 application, I hope Smile | :)


Som Shekhar wrote:
If a user defines a program priority as "High" or "RealTime" it only increases the share of thread time to current process. But no change in threading...


..and "realtime" isn't really realtime, but just the name of the highest level of priority.


Som Shekhar wrote:
If you look at any operating system that can support multiple processors, it automatically distributes work onto different cores.


Though it feels that way, it's an illusion. A program is made up of a logical set of commands/instructions that get executed one after another. That's reflected in our applications; we expect that the second instruction won't be execute before the first instruction. A short example;
10 A$ = "Hello"
20 B$ = "World"
30 PRINT A$ + " " + B$
These three lines of code should be considered atomic, meaning that you don't want to distribute them over 2 different people to interpret. This is a task that can't be divided. One processor had access to it's own cache, and it's memory. Windows was created and started to fake multitasking. Applications would run (to line 20 in our example), get thrown into the deep-freeze, another application would be defrozen and run, ad infinitum. Do that very fast, and it seems to become a fluid movement.

Threads we're already there; it was preferred to launch your own thread instead of spawning a new process if you needed to do some additional tasks. Using a thread would cost less resources and they behaved like an additional proces, owned by some other (main)-thread. Fibers were introduced also, but those never gained popularity.

You wanted this processing to happen in "some other place" than the thread that ran your interface. Every Windows-application has a method that's called "WndProc", which Windows calls now and then to inform your application of mouse-movements that have occurred, or that certain parts of the form need to be repainted. Let's extend our example application;
10 REM Example :)
20 REM
30 WndProc:
40    MSG = GWBASIC_INTEROP.GETMESSAGE()
50    IF (MSG = WM_UIT) THEN
60       GOTO THE_END
70    END IF
80    IF (MSG = WM_PAINT) THEN
90       GOSUB SAY_HI
100   END IF
110   GOTO WndProc
120 SAY_HI:
130    FOR X = 1 TO 100
140        PRINT "Hello World, number " + X
150    NEXT X
160    RETURN
170 THE_END:
180 
There's a loop that processes the messages, and there's code. This meant that if the processor was doing line 140, it would get frozen there in the middle of the job. This, as a consequence, means that the application wouldn't accept a "quit" message until it's finished doing those 100 iterations!

A thread is gets frozen with it's state, that's the reason why it's "illegal" to write into memory that another thread is working with, and the reason why the mainthread of any application is reserved to handle the UI.

The Parallel.For is an abstraction that creates multiple threads (let's take 4 as an example) to run a loop. One of the pre-requirements is that they shouldn't share variables that could mess up the way they work (because one has X=3, on X=4, and two have X=5). They should also say hello to the mainthread, before changing any of it's values. This model scaled to multiple processors.

SQL Express is limited to using a single processor, whereas SQL Server goes as far as making the processor-affinity a mere setting. Some applications still do their processing in the UI, easily recognizable by the white space that they show where a form should be. It's not a perfect situation, but it's often hard 'enough' to make an application run correctly with a single path-of-execution.

There is indeed a growing need for extra tools. The .NET Framework has a BackgroundWorker which makes it easy to manage a new line-of-execution, and you'll often find an Asynch-version for a method-call.

Som Shekhar wrote:
Brahma looks interesting!!!


Sure does - there's a lot of GPU's onboard of the motherboards in the office without being used very much Smile | :)

I are Troll Suspicious | :suss:

GeneralRe: Continued Values Collection/List/Dictionary Pin
Som Shekhar19-Dec-09 20:16
Som Shekhar19-Dec-09 20:16 
GeneralRe: Continued Values Collection/List/Dictionary Pin
Eddy Vluggen20-Dec-09 5:54
professionalEddy Vluggen20-Dec-09 5:54 
GeneralRe: Continued Values Collection/List/Dictionary Pin
Som Shekhar20-Dec-09 18:22
Som Shekhar20-Dec-09 18:22 
AnswerRe: Continued Values Collection/List/Dictionary [modified] Pin
Gideon Engelberth16-Dec-09 15:05
Gideon Engelberth16-Dec-09 15:05 
GeneralRe: Continued Values Collection/List/Dictionary Pin
Som Shekhar16-Dec-09 19:15
Som Shekhar16-Dec-09 19:15 
GeneralRe: Continued Values Collection/List/Dictionary Pin
Gideon Engelberth17-Dec-09 3:31
Gideon Engelberth17-Dec-09 3:31 
GeneralRe: Continued Values Collection/List/Dictionary Pin
Som Shekhar17-Dec-09 3:42
Som Shekhar17-Dec-09 3:42 
AnswerRe: Continued Values Collection/List/Dictionary [modified] Pin
BillWoodruff16-Dec-09 16:55
professionalBillWoodruff16-Dec-09 16:55 
GeneralRe: Continued Values Collection/List/Dictionary Pin
Som Shekhar16-Dec-09 19:17
Som Shekhar16-Dec-09 19:17 
GeneralRe: Continued Values Collection/List/Dictionary Pin
Som Shekhar16-Dec-09 19:19
Som Shekhar16-Dec-09 19:19 
GeneralRe: Continued Values Collection/List/Dictionary Pin
BillWoodruff16-Dec-09 19:41
professionalBillWoodruff16-Dec-09 19:41 
GeneralRe: Continued Values Collection/List/Dictionary Pin
Som Shekhar18-Dec-09 19:02
Som Shekhar18-Dec-09 19:02 
Questionproblem with the tcp connetion. Pin
prasadbuddhika16-Dec-09 6:24
prasadbuddhika16-Dec-09 6:24 
AnswerRe: problem with the tcp connetion. Pin
Paulo Zemek16-Dec-09 9:11
Paulo Zemek16-Dec-09 9:11 
QuestionSetup and Deployment Issue! Pin
Sr...Frank16-Dec-09 3:46
Sr...Frank16-Dec-09 3:46 
AnswerRe: Setup and Deployment Issue! Pin
Keith Barrow16-Dec-09 4:43
professionalKeith Barrow16-Dec-09 4:43 
AnswerRe: Setup and Deployment Issue! Pin
Seishin#16-Dec-09 4:46
Seishin#16-Dec-09 4:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.