« first day (964 days earlier)      last day (4208 days later) » 

00:00
I'm reading chapter 1.. I don't like jumping chapters.
Good read so far
He actually describes multi threading as asynchronous programming.. which I think is good
@LewsTherin you're one of those guys who reads huh? :D
Yeah
But understanding is another problem :L
you have so many stack points though, id expect you to be a guru
No, that's because I answer the easy questions.
It is easy to gain rep and know feck all.
dont be afraid to dive into code and create a playground test experience where you can check the performance and value between threads and tasks, just get them to do the same thing :P
haha
00:02
It isn't the performance and value I am worried about.. I want to know the difference
@LewsTherin: if i have a super long running background worker, ill spin up a thread
if i have a small concrete job/action, ill use a task
tasks are more suited for those types of things
and the code for it is a piece of cake
I know it is. I have used TPL without understanding what it is I am doing.
Does a Task have its own address space ? If it is just a method executing I doubt it.
But then again.. a thread also executes a method.. ugh. Bad explanation Travman ;)
Hmm, question. Within a Web Service how safe is it to start an asynchronous call to a synchronous method, and just let it go until finished and not care about the response?
if you need it as part of the response, you wait on it
if you dont, its ok to fire and forget
don't care about the response
Saving the incoming XML to file
I don't want it to hold up the execution of the process
I don't think this will mess the server up. I get 500 hits a second on this, which saves the XML fine. This change will just throw it to a new thread... wondering if it's better to force it to use a thread, vs async.
00:09
how are you doing the async call?
Using a delegate (.net 2.0)
AsyncDumpMessage caller = new AsyncDumpMessage(DumpMessage);
caller.BeginInvoke(null, null);
vs
System.Threading.Thread t = new System.Threading.Thread(DumpMessage);
t.Start();
yeah begininvoke should be fine
that's my thinking
@LewsTherin this is highly relevant ;)
How though? It doesn't tell me how the underlying operations between a task and thread is different :(
00:14
beginInvoke() and Task.Factory.StartNew() are pretty much the same
as far as the threads go
it grabs a thread from the thread pool, and queues it up for execution
Oh yeah that's right
Thinking about it.. if so why is that thread allowed to execute UI code?
It isn't the UI thread after all
which one
The thread chosen by BeginInvoke
00:16
oh nonon
this is delegate.BeginInvoke
that one from before is just a utility method for winforms so that you can run shit on the ui thread if you have a reference to a control
That's right. There is a difference
I can't see BeginInvoke on a Delegate type
But it is mentioned
Interesting, await actually "splits" the method
await is the pretty version of JS async programming.
I was wondering when you'd show up
Yeah it appears it does a lot of stuff for us
@LewsTherin you saved that pdf locally right?
00:28
k
Thanks btw
yw
What does it mean for a thread to be returned to the threadpool?
it frees it up so someone else can use it
its a pooled resource
Does that also mean the thread's address space and virtual memory are left intact
But replaced with new values
00:30
its been a while since school, but doesnt that shit belong to the process?
@LewsTherin I was 'here', just 'busy'.
@drch A thread also has its own local memory I believe
@LewsTherin Yes.
@KendallFrey Gotcha
im not sure if any threadlocal state would be overwritten
00:31
@KendallFrey Cool
@drch Threadlocal?
Yeah, you can make variables that have distinct values for each thread.
How do you do that?
@NinjaEcho look up threadlocalattribute
Dang, it is actually a thing
00:33
and Thread.CurrentThread.ThreadState
well, Thread.ThreadState
you can also name your threads. i usually name mine after transformers
Optimus Prime? :O
Bumble Bee? :L
actually our servers are always named after transformers ;)
for reals
Lies.. you can't be that cool.
windows boxes are autobots, linux boxes are decepticons
my laptop is ratchet
00:35
I think we have some named after LOTR or something.
Fantastic haha
It is LOTR! Damn I am good.
I hope I get to do that
I better
This book would have been better had it converted threaded code to Task based code
code runs on a thread
public void Foo() { }


new Thread(Foo).Start();
new Task(Foo).Run();
Well here you go
public delegate void AsyncDoSomething();
void DoSomething()
{
	System.Threading.Thread.Sleep(50);
}

void DoSomething1(object s)
{
System.Threading.Thread.Sleep(50);
}

void Main()
{

	System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
	sw.Start();

	for(int i =0;i<50;i++)
	{
		AsyncDoSomething caller = new AsyncDoSomething(DoSomething);
		IAsyncResult result = caller.BeginInvoke(null, null);
	}
	sw.Stop();
	Console.WriteLine(sw.Elapsed);
	sw.Reset();
	sw.Start();

	for(int i =0;i<50;i++)
00:00:00.0003153
00:00:00.0471381
00:00:00.0000065
00:45
SEEE
System.Threading.ThreadPool.QueueUserWorkItem is faster than doing the Async call, and loads faster than doing a new thread
do you really want to take the time to understand all that!?
I wish I had an electronics designer here.
I wish I had pizza... oh wait i`ll go buy one.
@drch If it helps me yeah
@RyanTernier Was this written for me? Or related to your own question?
@drch What's the underlying difference?
00:47
underlying difference?
@LewsTherin related to my own, but you were talking about threads so I decided to share it
I like to share stuff, not for anything personal, but I know people learn more when they see examples
I like to copy stuff.. so I copied it ;) danke
@drch Yeah.. what it compiles to.. blah blah
what what compiles too
00:48
Thread(Foo) and Task(Foo)
ah
Task just calls the threadpool
and new Thread(Foo).Start() will create a new thread
It compiles to the methods that you see in your code.
@KendallFrey But you said a Task doesn't have to spawn a thread... are you confusing me on purpose?
00:50
It doesn't spawn a thread.
it has to run on a thread
It gets one from the thread pool
And if there is no thread available?
The threadpool takes care of that
It either waits or makes a new one
The Task doesn't care.
Ok.. so that is what makes it asynchronous..
00:52
async isn't necessarily multithreaded
If it uses a thread how is it not multithreaded? Without that thread it will block
if it uses another thread then it is multithreaded
> The threadpool takes care of that. It either waits or makes a new one
but asychronous programming doesn't necessarily need another thread.
So is there a flag to specify that it shouldn't use a thread from the pool?
00:54
@LewsTherin one of the main things about async/await is that the programmer doesn't care if a thread is created or not
@LewsTherin no
I dont think so
if you dont want one from the pool, make your own
> Task just calls the threadpool
Does it do that implicitly?
ThreadPool.GetMaxThreads();
ThreadPool.GetMinThreads();
if none is available, and current < max, it will create a new one
And if there are no threads the Task can tell the pool to eff off?
00:56
I don't think so.
it just sits patiently and waits its turn
So it always receives a thread from the threadpool
assuming it doesnt starve, yes
How is that not multithreaded? Haha
It is
I never said it wasn't
00:58
Breaths deeply in and out. :L
> but asychronous programming doesn't necessarily need another thread.
I assume you are referring to other frameworks like Node then?
We're talking about a specific type of async programming, multithreading.
Even in C#, you can do async without threads.
async and await in particular are less likely to spin up another thread
So Task != async and await
Well, haha
async and await use tasks
01:00
a task is a wrapper of some code that needs to execute
the wrapper contains all the meta data about the result, the state, etc
the task runs on a thread
I think I see where the confusion may be..
a thread pool is a resource manager that will give up to N threads out, and then not give out any more until previous ones are released
@KendallFrey Are you thinking of this:
new Thread(()=>{ async await})
but if you create your own thread via new Thread() there is no limitation to the number of threads except the bottleneck of your cpu/os
@LewsTherin thats not even
01:02
Even what?
THEYRE JUST WORDS
"what is this i don't even"
It's not compilable
It's pseudocode man.. too lazy
DOES NOT COMPUTE
01:02
:L
pseudocode for what?
new thread async await purple bananas my nose
> Even in C#, you can do async without threads.
bah balh blah
new Thread(someFunc)
Where somefunc
Yeah, that makes a thread and runs it
01:03
async void someFunc()
{
   WebClient webClient = await some crap;
}
no
just no
Just no .. ?
you dont create a thread to call an async method
you just dont
just...
> Even in C#, you can do async without threads.
How can you use threads then?
Code plzz
dafuq
How can you use threads? By creating a thread and running it.
01:06
How to use threads + async
threads are async
so threads + async = threads
see above answer
> Even in C#, you can do async without threads.
How do you do async with threads
With a thread.
01:06
:L
Make thread. Run.
I just did and you were like "just don't"
Not that way
use normal methods, not async
When you used async in that statement you weren't thinking of the keyword were you?
I was, but not exclusively
async programming = new [] { threads, callbacks }
01:09
@LewsTherin check the first 3 paragraphs of this if you havent before blogs.msdn.com/b/ericlippert/archive/2010/10/29/…
@KendallFrey How do you do async without threads then ? Dude your words are really ambiguous
@drch I haven't thanks
@LewsTherin with async keyword
async was a fuckin awful keyword
Completely
you know if i remove my comments from this transcript, you guys sound like an abbot and costello routine
01:12
Never seen them :(
poor lews
and poor my brain
need sleep
or something
Same.. 2:13am
ive only been awake for 13 hours
Ok.. so async doesn't spawn a thread.. but its task does.
i get too much sleep
@LewsTherin ugh no
01:15
Ugh no.. and why?
It seems that the job of async is to keep track of the instruction after the long running task has executed
async creates a task on the current thread
hearken unto FetchAsync(…)
for sooth Romeo wherefore art thou FetchAsync(…)
:L
@KendallFrey Wait.. so async implicitly creates a new Task()?
Which in turn uses a thread from the pool.. right?
01:18
You change your tune like a woman changes clothes :(
Yeah blud
tasks from async keyword are special
@LewsTherin the thing about async, is it lets a lot of optimizatoins take place
say you have a webserver with 10 threads
a request comes in and you do a query that takes 10 seconds
if your not doing that asynchronously, that thread will be blocked
but async/await says hey you can go do something else until this is done
so that thread can be used for something else
01:21
Mmn.. in other words a threadpool sees that thread as available?
no its not in the threadpool
in theory, although im not sure about the implementation details
actually, maybe it is
but that thread can DO other work
if you dont do that, the os just gives that blocking thread a few cycles that does nothing, and then switches context to another one
if you get 10 requests at once, you can handle each one while another server is fetching your query, instead of waiting for the query to finish before handling the next request
01:23
await just means 'everything before this code can run before, after, or in paralell to the async method i need later'
you mean after this code?
do i?
wait.
grrr
no
we both wrong
foo():
bar();
var someResult = await SomeAsyncMethod();
await means it will wait until the async is completed
01:24
yes
But that's wrong
so SomeAsyncMethod() could run before foo();bar();, after, or during
but it all has to sync up after the await
@drch not before or during
01:25
If it waits that means it will block
It doesn't wait.
await blocks
it doesn't wait if you dont use await
"The “await” operator used twice in that method does not mean “this method now blocks the current thread until the asynchronous operation returns”. That would be making the asynchronous operation back into a synchronous operation, which is precisely what we are attempting to avoid."
oops
It doesn't wait.. nor does it block
01:26
it doesn't block the thread, but it makes it available to other events
a bit like thread.yield
sorry for not using proper casing btw
i feel wasted
Np
Ok so the thread can be used by another event while the long running process is being executed right?
What happens when that process is finished?
Is the thread reassigned?
@LewsTherin YES
But it has to wait for the other event to finish
@LewsTherin when its done it continues with the code after the await
await Foo();
await Bar();

== Task(Foo).Run().ContinueWith(Task(Bar());
01:28
@LewsTherin yes
@drch That would make it synchronous no?
relative to each other
but not relative the the calling code
thats what that thing you pasted meant
I need to sleep :L
async await basically says to the compiler, hey im gonna be sorta busy here. you can borrow my thread for a while til im done, k?
haha
its like vacation
use my car, but i expect it to be there when i get back
and you better have my result
01:33
@drch Mmn.. that sort of ruins your analogy no?
JS's is maybe like, hey would you do this for me and get back to me when youre don? i have other stuff to do until then.
yeah i fucked it but dont worry
actually, c# and js are pretty similar
c# just doesnt want to admit it
When you say JS are you referring to Node?
i prefer tasks over callback hell
01:35
@LewsTherin yeah but lots of browser stuffs do the same
i got a lot of experience with callback hell in python + tornado
Why does a async await get reassigned to the same thread?
Why not just choose another thread?
@LewsTherin dunno. simplicity/speed i guess
Sure I want my shiz back.. but if the "borrower" is executing a long running process won't that fuck things up
@KendallFrey Yeah I thought so
@LewsTherin yeah
but hopefully he uses async too
01:37
Let's hope :L
scumbag task. borrows your thread - infinite loop
someone sucks at PS
@drch Is there a part 1 to that link?
Do you have it?
@KendallFrey Yep
'async' is almost as bad of a choice as 'fabulous'
wait i have something
What is asynchrony?
the noun form of asyncronous
01:43
Kwl
yeah riiiight
Alright fellas. Thankz for bearing my stupidity. Now I have to sleep. Tomorrow shall bring another measure of stupidity.
Goodnight ;)
nite
02:17
hi
i need a help from you guys
what's your question?
 
7 hours later…
08:56
Hello guys! Could you help me with the ASP.NET automatic features with js
1
Q: ASP.NET JavaScript slash symbol escaping

Gelo VolroI'm working on ASP.NET project. And there is a one issue, which doesn't allow me to make a good webpage view. There is a piece of code: alertPanel.innerHTML = "some text<br />"; When I've have run such code, my webpage didn't render the <br /> tag. I tried to looked at the debugger and have ...

it does make automatic escaping for js
and I don't know how to fix it
please help! thank you
Hai...
Useually the HTML in webview navigate vertically
I want to load Horizontally
(navigation)
I have an idea that to restrict height of html size in webview
Please help me how to make it
hahaha
I didn't make any joke here..
10:04
i laugh because my program works brah ...
and besides this is c# room (not related to html) better go to php or css ... not here
oh.. concept is based on windows store app webview
C# is not related to HTML? What about ASP.NET? Or Store apps? Or Phone apps?
alright as you label it ... *accepted
10:29
@Elegiac you cant talk to other users like that !
lol .. I just said !
haha ok ... i just feel offended bout this line: "I didn't make any joke here.. "
If I could kick this guy out.. I'd
what guy?
@JohanLarsson Elegiac
10:33
but why?
i hope you know ... it get you to chat ban
Unfortunately you can't just kick someone out of a room as owner. A tad sad, really.
but not many times kicking out is needed
@RoelvanUden Yeah
10:35
@RoelvanUden convert it to gallery ... with automatic approve by boot ... and once you find anyone trolling revoke his access ...
what does approve by boot mean?
By bot, probably. There should be build-in functionality :P
There are so many bots in here, tweak one to do that !
@JohanLarsson i mean give access to post comment
Quick question on MVC
I have a user entered detils on a form, on clicking 'submit' button i stored them in db. now user enters his unique code number and search for details, how do i bind his gender in dropdown ? i know he's male, dropdown has 3 values(M,F,O) ?
@Html.Dropown(m => m.gender, (IEnumerable<SelectListItem>)ViewData["GenderMaster"])
10:59
?
Jez
Jez
use @Html.DropDownListFor(model => model.Gender) and set model.Gender to the appropriate value before passing it to the view

« first day (964 days earlier)      last day (4208 days later) »