Welcome
Ladies and Gents:

These forums are now closed and registration disabled.

Please join us at our new forum on Proboards. Our hope is that these new forums are more stable, provide more and better features, and allow continuation of the project forums in a safer, more secure, long term environment.

me3explorer.proboards.com

--The ME3Explorer Team

NET 4.0 Tasks and Continuation Options

Coder-centric area for programming advice and questions.

Re: NET 4.0 Tasks and Continuation Options

Postby Fog.Gene » 23 May 2013, 23:53

I used try-catch with aggregate exception before to handle it, as already was discussed in the links you posted above, the difference is he's using it outside the main body of the Task. It is a nice solution and the task gets set to cancelled, I'll give that a go next time I mess around with the Tasks. In my method it is quite clear I don't actually cancel the Task, only check for the CTS status to decide what to do next.

That article is more interesting to me right now because of the Synchronization Context stuff. I use them inside my Tasks to post updates in the main GUI, but instead of tying them to the Task (which I didn't know it could be done), I post them manually. That I'll try asap hehe.
Regere: Let the world know of its sovereign. I shall be the rule by which all things are measured.
Polyhistor: Then I am to be the slave, for all things shall be my master.
Fog.Gene
Emeritus
 
Posts: 259
Joined: 20 Feb 2013, 05:09
Has thanked: 119 time
Have thanks: 65 time

Re: NET 4.0 Tasks and Continuation Options

Postby Fog.Gene » 25 May 2013, 11:27

Sorry for double post, but since I got the attention of someone that used Tasks, might as well ask here...

I've been wondering something for a while, but it's hard to explain. Like the guy in the codeproject article, the method that I use to call the Tasks has some extra code in it: For example, I call an instance GUI and listen for a delegate onclickedbutton event (yes, the cancel button in the GUI), I check for Task state and even post updates to the GUI, etc...

It seems that while the Task is running the thread/method that called it remains active, not looping or anything like that, just active. Look at the article's code, that's exactly why those try-catch outside the main task body work so nicely. I always thought any code I wrote ran sequentially from call to end. It looks as if when running a Task that concept goes out of the window.

Don't get me wrong, I use it and love it. But why is this?
Regere: Let the world know of its sovereign. I shall be the rule by which all things are measured.
Polyhistor: Then I am to be the slave, for all things shall be my master.
Fog.Gene
Emeritus
 
Posts: 259
Joined: 20 Feb 2013, 05:09
Has thanked: 119 time
Have thanks: 65 time

Re: NET 4.0 Tasks and Continuation Options

Postby mnn » 26 May 2013, 20:57

I'm not sure if I understand what you mean. But regarding "the thread/method that called it remains active", it is because when you call Wait on Task or you want to get the Result property and the task has not finished yet, you will "wait" there, until it's finished.

But again, I'm not sure if that's what you meant.
mnn
User
 
Posts: 42
Joined: 22 Aug 2012, 17:10
Has thanked: 1 time
Have thanks: 15 time

Previous

Return to Coders' Help

Who is online

Users browsing this forum: No registered users and 0 guests

suspicion-preferred