« first day (965 days earlier)      last day (4206 days later) » 

00:01
Do yo guys know of a diagram that shows the structure of a thread and process ? address space, virtual memory, executable code etc.
So I can keep it as a reference
@Pheonixblade9 Interesting
@LewsTherin No, but I can sum it up.
Threads share code, data, and address space, but they have separate stacks, and a little bit of thread local data
A process is a bunch of threads that share the above
Since you've done WPF you are familiar with the main UI thread right?
00:12
Do you have an idea how that thread works?
I don't think it's special in any way other than that it's the one that started the event loop.
It updates the controls etc.. I assume that requires some loop
I think you could create your own UI thread should you so desire.
So the main UI thread keeps track of events in the event loop
I'm wondering how BeginInvoke marshals data to the main UI
I'm guessing it uses the event loop.
Either that or the OS interrupts the thread.
You couldn't do it in ordinary code.
00:16
No, that throws an exception.
What does?
Updating a control on a thread that didn't create it.
I'm not talking about that.
2 mins ago, by Lews Therin
I'm wondering how BeginInvoke marshals data to the main UI
I'm trying to explain that.
Protip: Use Invoke, it's simpler.
That blocks..
Yeah
Who cares
00:18
The user? :P
it wont make anything unresponsive, anyway
if you're doing long-running operations in invoke, you're screwed either way
Yeah that sucks
Wtf..
That was weird..
haha
I said "I'm fused" instead of "I'm confused"
I assumed that was a new slang
It would be if I said confussed.
> An exception might be thrown if the thread that should process the message is no longer active.
Strongly indicating Invoke uses the message loop.
00:22
BeginInvoke uses a threadpool thread.. so how does it update the UI?
Does it call Invoke maybe?
@LewsTherin Whaaat
What do you mean?
It calls the UI thread.
You are mostly right.. I was completely wrong :L
> Executes a delegate asynchronously on the thread that the control's underlying handle was created on.
The UI thread
> on the thread that the control's underlying handle was created on.
Not guaranteed to be the UI thread
That is by definition the UI thread
00:27
So any thread that creates a visual control becomes a UI thread - just not the main one?
I guess you would say that
Her voice..
accent.. whatever.
So how'd BeginInvoke execute stuff on the UI thread
I stopped when she said VB
@LewsTherin It asks the OS to.
00:30
@KendallFrey Haha
I don't expect an old lady to know much about programming.
@KendallFrey Yeah.. but what happens exactly? Does the OS inject the code to the main thread
@KendallFrey Tut.. ageist and sexist.. great!
ageist?
@LewsTherin It sends a message to the message loop (I assume)
@KendallFrey I figured it was worth a shot
@KendallFrey That sorta make sense.. so then the UI thread can process it. However.. if only a thread that creates a control can update that control... does that thread implicitly have an event loop?
I'm not sure if you can make a control handle without an event loop, but I wouldn't be surprised if you could.
I don't think you could interact with it at all.
00:36
With the event loop?
I have no idea what would happen if you Invoked.
@LewsTherin With the control
I could try it now.. but I think it should just update on the thread that created it
I still don't get how the main UI thread checks its control for updates. It can't be an infinite loop processing the event loop otherwise our code won't execute..
@LewsTherin It is an infinite loop. When it receives messages, it calls the appropriate event handlers (including your code)
Any idea when this loop may be executed?
Probably after InitializeComponents()
From the time you start the program until it ends.
Application.Run starts it. Application.Exit ends it.
00:42
But after having created the controls first.. otherwise it would block (not show any window)
Uh, no...
It starts the event loop, which receives some sort of initialization event that creates the controls.
I may be wrong, though.
That could be right as well haha
The .NET controls are created before the loop starts.
I'm not sure when the Win32 controls are created.
Np.. I will create a Label on a sub thread now.. and try to update it in the same and another thread to see what happens
Uh.. no luck
 private void createThread(object sender, RoutedEventArgs e)
        {
            Thread t = new Thread(() =>
                                      {
                                          Label label = new Label();
                                          label.Content = "Hello World";
                                          wrapPanel.Dispatcher.BeginInvoke((Action) (() =>

                                                                           wrapPanel.Children.Add(label)
                                                                          ));
What am I doing wrong there?
Culprit: wrapPanel.Children.Add(label)
Oh I know why.. label wasn't created in the main UI thread
That puts an end to the stupid test
00:57
Try updating it without actually adding it the the form
Yup.. updating on the god thread is fine. Even updating it on the main UI gives a middle finger.
Wow, that's a feisty Label.
See if you can create and show a Window on another thread.
Ok
Mmn.. disappears very quickly
It is window.Show() right
Yeah.
You'll probably need to start a new event loop.
But it throws no exception.
I just realized you can't assign a lambda expr to an implicitly typed variable.
02:10
 
3 hours later…
05:21
Good morning PiPz
 
1 hour later…
06:40
@Elegiac No need for that?
1 message moved to recycle bin
@Johan , soon he will bring another break up in here :P like the one happened few months ago.
No it will be fine :D
yeah. hope so.
:)
i just found out ppl here take it too serious . i think that what geeks is all about .no time for joke .
but i already knows it now so i guess ill be ok
Joking is ok, maybe the problem was that the guys yesterday were not sure you were joking?
But lets not think about that more, I also got temp-banned once :D
06:54
no as ive said yesterday i just feel offended on what that guy SAID .but in the end i accept my mistake and admit it . in fact i sorry for what ive said but this 3 was crying like a baby and wanted me to ban ... 1st ban me 30mins then became 1hour ...
@Elegiac, you cant expect anything, I am alright with jokes. :P but few other may not take it easy as we do. one of those three people you mentioned has brought a big break to this few months ago and lost many good users. So, I just wish this room exists forever and alive with good users..
it wouldnt be alive if this room would have a bossy 1 like what those 3 shows
and the cause of ban was because i say im sorry nigga? lol hahaha
but im not mad though but you cant change my mind that those 3 are retarded crybabies hahaha .ban me if you want with this line dont care now atleast i already said my thoughts about them ...
Sounds good enough, no need to love everyone as long as there is not constant fighting
fighting produces so much noise :D
lol..take it easy guys. lets roll. how to bind dropdownlist in MVC 4 ?
I got to go to the beach now so you wont see my forehead flare for a while now
07:03
i have generic list collection and i got value in controller..but I cant assign value to ddl ?
ha ha Johan, beach ? have fun.
07:38
anybody here ?
@codebrain Can you show some code depicting your issue?
0
Q: Retrieve value of dropdownlist after saving to database on a button click

coderI am Working in an MVC4 application where i need to save the dropdownlist value and retrive it from database.I have saved the value to the database but cant retrive back the value on click of a button .CsHTML: @Html.DropDownListFor(m => m.Gender, (IEnumerable<SelectListItem>)ViewData["GenderM...

that's the link @roelvanuden
@codebrain I'll join the comment, "Please provider more details and code samples. How does your view and controller look like.". This question does not give enough insight into your controller/view/enums.
I have a dropdown control with gender details. (Male, female, other).
user selected 'female' and fillled all details and submitted the form.
after successful postback i retrive the form data again and display it to use. now, i get the value of gender as 'female' in controller, but Dropdownlist is loading with default initial value "Male". That's my issue, how do i load female in gender dropdown ?
07:55
hello all,
I'm new to VS. I have a form that's maximized. I want a panel to be placed in the middle of the form. How can I achieve that? Is it possible to use only properties, I would rather not do it programmatically... want to use just panel properties
08:11
I just stuck with loading dropdown with known value :P :(
@iroegbu set the anchor property of your panel to none
it is set to none
somebody just tell me, a dropdown has 3 values(1-male,2-female, 3-other), when the form loads, i want to load the 'other' in the dropdown. how ?
I use @html.dropdownlistfor(m=>model.gender, ViewData["genderSource"])
08:32
index ? what..i dont get you
in dropdown you make other as index ... when it loads 1st to see was "others"
i dunno if the dropdown your talking was related to combobox tool (c#) but if thats what you want then make an if else condition about it ... but if not i misunderstand it then sorry ^^ hehe
how to make it ?
i dont want others to load always..based on the user, the gender should display
if i understand it correctly when a form loads dropdown index was null or -select gender- (without any value) then when you choose female value female will go into database, then when you reload it , it will turn back to null ...
i have a code of that in "php" that loads data from database to combobox again .like when you want to edit it , if you once selected female, then female will load in combobox as index... but the sadest part was i dunno how to make it in c# ...
Hello
09:30
Thats okay @Elegiac
ill buy new book of c# tomorrow
i guess i need to read in order to learn fast ^^ though i really hate books
Or.. books hate you.
Which isn't a feat in itself.
nope ... crybabies can be hahaha
@codebrain, by the way in gender bro since your using a dropdown, you said you use male, female and others ... you can replace others with "LewsTherin" hahaha
huh, books ? i have them., no use now. books wont help for recipes. onlly knowledge/
09:49
And stop whining like a "crybaby".
Perhaps, in order to avoid pissing off everyone everywhere you go, you should begin to write with some respect towards other individuals.
Continuously throwing around "niggas" and trying to sound "cool" does not help.
He has two accounts.. one for trolling and another for even more trolling maybe.
Perhaps. It is people like this that, after a warning, continue to act respectless that I would like to have more administrative powers for channel owners. Fortunately, reporting does give usually give quick results but this guy will come back and start the whole thing all over again. :-(
Yeah :'(
@JohanLarsson If you get on.. ping for some WPF play
I miss an asynchronous version of Dispose :D
09:58
Mmn.. why'd you want that?
"miss".. is this in Node already?
Confused level.. rising
I have a custom HTTP server for my final assessment and a HttpContext (the object containing 'Request' and 'Response' values) is Disposable. When it is disposed without writing something, it has to write 400 Bad Request and that should be using async/await. However, Dispose is not async :)
So where everything else is 100% asynchronous and using completion ports (thus not consuming any thread), a bad request will be locking one thread from the thread pool while writing. :P
@RoelvanUden Writing something to the Response object yeah?
Jup, so I need to Wait on the Task doing the write. That's just fine, but it consumes a thread and the inner nerd in me doesn't want that :P
Mmn.. but writing to the Response object should take ms (I think, meaning not worth the overhead of starting a new task). You shouldn't need another thread just for that.
Do you know the performance difference between CPU-bound work and I/O-bound work?
10:04
I/O is more expensive, but I don't know the exact percentage.
It is about 1000x slower for most operations. Are you familiar with completion ports?
It's very interesting. In the core, a completion port is nothing more than telling the OS you are doing something and want to be informed when it is done. For example, requesting an internet resource; the application requests the data and tells the OS to inform when it is completely downloaded. The OS does its work, with all its optimizations and love, and finally tells the application "Hey, your resource is here. Catch!".
Seems as if the completion port itself is a threaded model
By doing so, the application doesn't need to consume a thread (with its own registers, stack with parameters, and so forth). It just needs to handle the "Done!" message the OS sends back. This saves memory, but also removes the need for that additional thread and won't cause thread context switches (which is how a OS updates all running threads, switches to them to let them run).
It saves memory and CPU which is very cool. This is how Node operates as well.
10:08
But Dispose isn't an I/O bound operation
So doing a Wait does leave that thread hanging (context switches using CPU) and consumes more memory :-)
True! But my Dispose is actually writing onto the network.
So it cannot make use of completion ports and remove the thread until it is done, it's not asynchronous :)
Oh
Can't you just tag an async and await on the Dispose method.
Now imagine someone is DDoS'ing the server and causing that 404 code in the Dispose function to run. I might end up with thousands of threads doing writes all the time, really clogging up my server.
Nope :-(
Why not?
It's not specified in the IDisposable interface
And using will not work without IDisposable :-)
10:11
Mmn, I don't think it matters.. or does it?
async isn't part of the signature
True, but Dispose should then return a Task but it doesn't.
Even if it is a void method?
public async void Function() is actually compiled as public Task Function()
async void becomes a Task that can be awaited.
Then the compiler magic will split functions into pieces to be completely asynchronous.
Oh right.. so it changes that sig too. Bum
Is async await only used for IO operations? It seems that's what it was designed for.
Pretty much, yeah, it doesn't make sense to do CPU-bound work with async :)
10:15
Why not?
If the CPU bound work is a long running process.. it makes sense I think.
You don't have to wait for anything, just do your calculations full blaze :)
Then you do it threaded, but not asynchronously :)
What if the result of the CPU bound work is needed? A callback mechanism would be useful for it.
Instead of saying thread.join()
Yeah you usually would have a delegate or event of some kind (e.g. a BackgroundWorker provides a WorkCompleted event).
Food, AFK for a bit.
10:34
why the dropdown in MVC is so stubborn ?
How do you write asynchronous file IO without using the inbuilt API?
Man, I'm learning so much shit instead of enjoying my vacation. :L
var task = Task<FileData>.Factory.StartNew(()=> DoSomeFileiO());
DoSomeCPUBoundShiz();
var result = task.Result;
DoSomeShitWithResult(result);
Yeah, but how do I make DoSomeFileIO asynchronous in its file reading.
what do you mean
the io should be asynchronous relative the the cpu bound operations
not asynchronous relative to itself
brb
Ok back
Unlike CPU operations, IO operations can be done asynchronously or synchronously
@drch What you wrote was threaded File IO.. not threaded asynch file IO
Do you follow?
10:46
no
StreamReader reader = new StreamReader()
while(..)
{
   reader.readLine()
}
That is pure file IO, not asynchronous, not threaded.
However... using a thread or a task:
new Thread(readFile)
new Task(readFile)
The file reading is now executing on a background thread.. however still not asynchronous yeah?
sure it is
if its done in another thread those two threads are not synchronized
Ok that was ambiguous. Asynchronous in the context of IO asynchrony
yeah youve kinda lost me on this
Let's forget about threads.
StreamReader reader = new StreamReader()
while(..)
{
   reader.readLine()
}
That is file reading synchronously.. how do I turn that asynchronous without using threads, tasks.
I don't think even async await would help.
It would stick block because the current thread is in a wait state.
10:51
that thread would block sure
not every step in an async task is async
the process itself is async
 async void ReadFile()
 {
  StreamReader reader = new StreamReader()
  while(..)
  {
   reader.readLine()
  }
}
Mmn.. is that right? Can I use async without await?
i dont think so
i dont have VS 2012 here, but i dont think that will compile
Sync
---- var data = ReadFile() --- DoSomethingElse() --- ProcessData(data);

Async

---- DoSomethingElse() ----- (wait) ------ ProcessData(data);
 \                                    /
  ------------ReadFile()-------------
@drch Is ReadFile() executed in a background thread or using a Task in the Async model?
task yes
@drch It compiles..
10:56
ah might be a resharper warning then
@drch No no no.. I could do that but that isn't Async File IO
i dont think theres a major difference between
return new Task() { streamreader.ReadLine())
and return streamreader.ReadLineAsync()
If you do ReadLine instead of await ReadLineAsync the calling thread goes into blocking mode.
Until the IO operation is completed.
Yeah to both of you.. I'm just wondering how to use the OS asynchrony without using threads or tasks
If I can do that.. it shouldn't block
It's going to be a lot of low level code I imagine
Actually, it really is not. :-)
10:59
so you dont want to use threads tasks await/async?
wtf
spin up another process?

« first day (965 days earlier)      last day (4206 days later) »