Click here to Skip to main content
15,893,668 members
Home / Discussions / C#
   

C#

 
AnswerRe: Open Auto Cad File Pin
Richard MacCutchan17-May-11 21:21
mveRichard MacCutchan17-May-11 21:21 
AnswerRe: Open Auto Cad File Pin
Dalek Dave22-May-11 0:38
professionalDalek Dave22-May-11 0:38 
QuestionUsing threads to process a collection [modified] Pin
LetMeFinclOut17-May-11 15:03
LetMeFinclOut17-May-11 15:03 
AnswerRe: Using threads to process a collection Pin
Not Active17-May-11 16:30
mentorNot Active17-May-11 16:30 
GeneralRe: Using threads to process a collection Pin
LetMeFinclOut17-May-11 17:13
LetMeFinclOut17-May-11 17:13 
AnswerRe: Using threads to process a collection Pin
Luc Pattyn17-May-11 18:30
sitebuilderLuc Pattyn17-May-11 18:30 
GeneralRe: Using threads to process a collection Pin
LetMeFinclOut18-May-11 0:49
LetMeFinclOut18-May-11 0:49 
GeneralRe: Using threads to process a collection Pin
Luc Pattyn18-May-11 1:59
sitebuilderLuc Pattyn18-May-11 1:59 
Of course there is a difference, a rather big one.

In multi-threading you write code in sequential mode: lets do A, then wait for B, then do C, then wait for D, etc. That is easy to write as the program counter is your main state variable; now each thread needs a stack (so it can remember where it is when nesting functions/methods), and the operating system has to switch threads all the time.

In asynchronous operation, you could have just one thread; the workload is split in small jobs, and the thread executes these jobs one at the time, to completion. That is how Windows does a WinForms GUI: you have a button handler, a paint handler, etc. Now if you need to split a long-winding operation over multiple handlers, you need some state variables, you basically build a state machine, which is event-driven, not progressing based on the program counter.

Consider a serial port receiver: with its own thread, you can write like: now I expect this, then I wait, then I should get some acknowledge, then wait, then get a length, then some amount of data, etc. With a DataReceived handler, your handler has to reflect on "what am I getting know" and "where was I in the protocol", and make those match up.

Smile | :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

GeneralRe: Using threads to process a collection Pin
BobJanova18-May-11 23:16
BobJanova18-May-11 23:16 
AnswerRe: Using threads to process a collection Pin
Luc Pattyn17-May-11 16:30
sitebuilderLuc Pattyn17-May-11 16:30 
QuestionListView Pin
wizardzz17-May-11 11:21
wizardzz17-May-11 11:21 
AnswerRe: ListView Pin
gavindon17-May-11 11:24
gavindon17-May-11 11:24 
AnswerRe: ListView Pin
RobCroll17-May-11 16:36
RobCroll17-May-11 16:36 
AnswerRe: ListView Pin
Mycroft Holmes17-May-11 19:47
professionalMycroft Holmes17-May-11 19:47 
AnswerRe: ListView Pin
Shameel18-May-11 0:27
professionalShameel18-May-11 0:27 
GeneralRe: ListView Pin
wizardzz18-May-11 8:24
wizardzz18-May-11 8:24 
QuestionHow to detect mouse over and out on windows title bar Pin
Tridip Bhattacharjee17-May-11 3:43
professionalTridip Bhattacharjee17-May-11 3:43 
AnswerRe: How to detect mouse over and out on windows title bar PinPopular
Dave Kreskowiak17-May-11 4:58
mveDave Kreskowiak17-May-11 4:58 
QuestionSelecting elements from array at specific indices Pin
Chesnokov Yuriy17-May-11 1:25
professionalChesnokov Yuriy17-May-11 1:25 
AnswerRe: Selecting elements from array at specific indices Pin
Luc Pattyn17-May-11 1:54
sitebuilderLuc Pattyn17-May-11 1:54 
AnswerRe: Selecting elements from array at specific indices Pin
Chesnokov Yuriy17-May-11 1:58
professionalChesnokov Yuriy17-May-11 1:58 
GeneralRe: Selecting elements from array at specific indices Pin
Luc Pattyn17-May-11 2:01
sitebuilderLuc Pattyn17-May-11 2:01 
AnswerRe: Selecting elements from array at specific indices Pin
Wayne Gaylard17-May-11 3:48
professionalWayne Gaylard17-May-11 3:48 
AnswerRe: Selecting elements from array at specific indices Pin
Luc Pattyn17-May-11 4:17
sitebuilderLuc Pattyn17-May-11 4:17 
GeneralRe: Selecting elements from array at specific indices Pin
Wayne Gaylard17-May-11 4:24
professionalWayne Gaylard17-May-11 4:24 

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.