« first day (1314 days earlier)      last day (3860 days later) » 

18:04
lets discuss taskcompletionsource
so, the reason that we don't want to use StartNew to create new tasks has been discussed, and we should be using TaskCompletionSource to manage and create our tasks. StartNew forces multithreading. However, all of the examples I find online that use TaskCompletionSource use ThreadPool.QueueUserWorkItem, which also pulls from the threadpool (like StartNew)
so my question is: wtf
or, since nobody is responding: how do you populate the result of a TaskCompletionSource without eating up threadpool threads
@Steve Read the comments at the class declaration, it might shed some insight.
@Steve call SetResult
okay, so
//huge database call thats blocking
tcs.SetResult(dbresult)
doesn't help much
why not?
18:11
because its blocking the thread during the huge ass database call, right?
One of us is missing something, and it's probably me, and that's your fault. :P
@Steve Why is that a problem exactly?
its a long explanation, that you must've missed a few months ago :)
but, to sum it up as vaguely as possible
iis gets a request, uses the clr threadpool, if you have a highly-trafficked website or service, and that thread is blocked, you get thread starvation
iis won't be able to handle new requests, and your http.sys will start throwing 503's
@Steve ok, so you don't want to be using synchronous db calls. Where does TCS come in?
okay cool, so where the TCS comes in is.... lets say i'm just using plain ado.net, and i want that stuff to be ran async, so it doesn't starve the threadpool, i can do Task.StartNew() and throw all of my code in there, but what start new does is actually introduce multithreading - e.g. it pulls from the same threadpool that the current thread is returned to when you do the whole async thing
so I use TCS to create the Task instead, now how would i populate the result in an async manner?
e.g.
// huge ass database call thats blocking
tcs.SetResult(dbResult);
18:18
So you're saying the DAL doesn't offer any async methods?
i'm talking about creating my own async method, to be more specific
Answer my question so we don't get confused.
there is no DAL.
there is no code.
How are you accessing the DB?
THERE IS NO SPOON MOFO
back on topic
plain ado.net, lets say
lmao
so, lets just say
18:20
!!there is no spoon
@EvanL Yes!
internet isn't working, standby
Yeah, does ADO.NET give you any async alternatives to what you're using?
probably, but i wanted to learn how to create one of those async alternatives
If you use a synchronous db call, you will always tie up one thread, no matter where that thread is.
You can't magically make sync into async.
18:24
@Steve you should watch that talk I've linked to. It covers situations like yours too
well, when we do await, the thread gets sent back to the CLR threadpool, and offloads the work to a windows thread, when windows is done, it hits the clr threadpool, spins up another one with its result
you should not try to pack synchronous code inside Task to fake async
@MarcinJuraszek i definitely will
if your db access provider (ADO.NET in this case) does not provide async methods, there is nothing you can do to make it work async in a good way
unless you rewrite the provider to work async
or use different one
@KendallFrey what I'm saying is. lets say you make a web service call, you do it async, you get the CLR thread back so IIS can use it in other requests, it offloads the work to the kernel (or something), and when that request is finished, the kernel talks to the CLR (or iis?) and gets a new thread, and execution of your code starts again, with the result obtained by the kernel
18:26
Right, but only if the call is async
i was just using a db call as an example
By that I'm not referring to the async keyword specifically
so, if i follow all of you correctly: don't worry about it, use the built in methods
anyway, have a meeting, fires are burning ttyl
You can't make synchronous logic asynchronous. If it needs a thread to hog, it needs a thread to hog.
it depends where that thread comes from which makes your application scalable or not
if you're blocking CLR threadpool threads, then your visitors will be pretty pissed, if you offload it to windows, your application is extremely scalable
18:29
If you're looking to learn stuff, try implementing an async wrapper around a callback-based async call
ee
thread is a thread, no matter where it comes from.
I'm guessing most async stuff has callbacks under the hood
and you should not hold one for io-bound operation
(yes, db call is IO operation)
@MarcinJuraszek thats true, but not true, brb
async calls don't even block a kernel thread
@KendallFrey but they block your...
@JohanLarsson no if you use async/await!
I would guess that most synchronous IO methods are wrappers around async calls, either at the OS or app level
@MarcinJuraszek it was a lame joke :)
@JohanLarsson cock? lol
18:34
#two day streak
sorry, didn't get it :)
!!urban cockblock
@KendallFrey cock block One who prevents another from scoring sexually.
@MarcinJuraszek be glad
public class SomeClientProxy : ClientBase<ISomeClient>, ISomeClient
^ I don't understand that
is that another joke?
:P
18:39
nope
I just don't know wcf
oh, is it a WCF proxy?
yes, it lacks async ~overloads~
don't know why that way is chosen compared to having VS generate it is even posible
you have to declare your operations as async
[ServiceContract]
public interface IServiceContract
{
    [OperationContract]
    string Hello(string name);
}
do Task<string> HelloAsync(string name); instead
but I've never actually done that
It's been a long time since I used WCF
I made a toy project and then every method had an Async version automagically
@MarcinJuraszek will play with it ty sir
@ton.yeung EDM?
Electronic Dance Music (over-arching genre for things like Trance/Drum and Bass/House etc...)
18:58
Hm, what could cause UI kinda flickering when dragging it around while doing some io-stuff (even though it's not on the main thread)?
@RodrigoSilva What framework? WinForms? WPF?
@RodrigoSilva WPF app? the framework itself.
WPF, yes
Yeah it's the framework... redrawing probably.
Ehm... But if no control is being updated, why should it behave like that?
Let's assume the task being executed takes no action on the UI
And it doesn't
If said task is not being executed, it drags around just fine
19:01
ask the WPF team
flickering when dragging would indicate the view is being rendered each time the dragged item's position changes
Will do, I'll whip them all right!
The only control the task was updating was a progress bar, which I turned off to test it out. Same behaviour
Does your background thread update the UI in any way?
Ah that answers that...
@RodrigoSilva Is the background task using alot of processor on your machine? Could be windows causing the issue (unlikely, just a thought).
@EvanL No, not really. It's not really IO-bound, it decrypts and decompresses some stuff (but according to the task manager, it's barely nothing). It's writting 2 filestreams, though.
Shouldn't be an issue then.
19:06
The process is like this:

-> Read an index file to get file data and its offset on the *pack file*
-> Read offset to offset+length from the *pack file*
-> Decrypt and decompress data
-> Write it to the disk
All while dragging?
when you turned it "off" did you comment out the code that hooks up the progress report binding?
Wow, my chrome just died. Yes @TravisJ
Yes @NETscape
Lol we're all thinking the same thing is the problem ;)
What is it?!
19:08
Well... I was thinking it was the binding. Not sure now.
Is there a way to monitor how much RAM your C# application is taking up programmatically?
errmm I guess just memory in general
Oh nevermind, it's actually the updating of the progress bar...
This might be easier. I have a Dictionary<[CustomKey], [CustomClass]>
But it's a bit weird, I commented out the part which does the update, same behaviour.
I removed the actual binding, no flickering
posted on May 22, 2014 by The .NET Team

This post was authored by Morgan Brown, a Software Development Engineer on the .NET Native team. It is the third post in a series of five about Runtime Directives. Please see the two posts in this series, Dynamic Features in Static Code and Help! I Hit a MissingMetadataException!, before reading this post. Sometimes the only thing worse than having your app throw an exception is having it not

19:10
I add to it dynamically and I add to its values dynamically, I want to know if it ever gets bigger than X MB
@RodrigoSilva Right it was still trying to bind, it just wan't doing anything to the UI Element.
So, I should set an interval on the updating?
@user1596244 - There is no good way to measure. The closest approach would be to turn it into a bitstream and measure the length.
@RodrigoSilva Is the progress bar on your main window?
@EvanL It is.
19:11
@RodrigoSilva - throttle
@RodrigoSilva aye throttle
What would be the best solution then?
@TravisJ link to something that might explain that? "Turning object into bitstream" ?
I need to update the progress, but I can make it less often, that should fix it... Right?
@RodrigoSilva At the very least it will reduce the flickering. But I'd guess it will flicker when it receives the message to update.
19:14
are you using the ReportProgress event @RodrigoSilva?
do you know about the command paste xml/json as classes in VS?
@NETscape Nope, I'm passing an action to the worker thread, which sets a value. On my VM I just update the progress bound property.
hm
// Update progress
actionProgress = (totalFilesCounter/ (double)workingList.Count * 100.0);
progressCallback(operationResult, (int)actionProgress);

That's the worker method
Can you post progressCallback?
@RodrigoSilva Also java naming much? ;)
(operationResult, globalProgress) =>
{
ActionProgress = globalProgress;

if (operationResult == 0)
_successCounter++;
},
It hurts my soul
19:17
That's the lambda expression which updates the property
Why is it bad? :O Shouldn't I use camelCasing?
@RodrigoSilva In C# method names should be PascalCased
stuff like this makes me sad $($el)
@EvanL Oh, I do name it like that. But since the action is a parameter, it felt wrong.
19:19
@RodrigoSilva Ah I see, thought it was just a call to a method.
I'm picky about formatting ;) Has nothing to do with your problem ;)
@RodrigoSilva have you tried CurrentSynchronizationContext?
19:39
Annnnd, we're back
!!urban rodrigo
@TravisJ Rodrigo A person who wants everything with reproductive organs. A walking hormone. Even though a rodrigo is usually harmless you must have firm handle on his outgoing attitude. But rodrigos are still usually well-liked, everyone knows a rodrigo.
lol :P
Noooo, it will follow me forever
Wheeee!
19:40
About the problem
@NETscape I haven't. I tried introducing an interval, it only updates the view when progress changed at least 5%. It reduced the flickering greatly. Feels hacky though.

@EvanL I like to have every name neatly formatted aswell :P
Almost had to actually get back to work there for a minute ;)
You kinda get hooked to this chat :P
And the community in general
Yeah... might be a problem at the new job. But I doubt it ;) I will just be less engaged here.
I've basically been doing nothing since I put in my notice as they haven't really talked to me much. Documented all my code, trained the IT guys on programs etc... now I'm just waiting to leave ;)
You're going to a game-dev company right?
wow
the cdn just went offline
for se
19:42
Yep games/robotics
They must be replacing their redundant power supply
@TravisJ The UPS plugged into itself? ;)
Sorry to push the subject again, but my solution feels kinda hacky and it doesn't solve it entirely. Is there any better way?
?
Did uh, did anyone notice that the chat record was just deleted
34 mins ago, by Johan Larsson
do you know about the command paste xml/json as classes in VS?
found it today, a nice one
glad you asked :)
19:50
nvm
you moved it then edited your message
1. Copy some xml into clipboard
2. Create a new class in VS, delete everything in it
3. edit > paste special > paste xml as classes
4. Profit
Now try it!
I don't blog
@TravisJ did you try it?
@JohanLarsson - Sorry, try what?
23 secs ago, by ton.yeung
3 mins ago, by Johan Larsson
1. Copy some xml into clipboard
2. Create a new class in VS, delete everything in it
3. edit > paste special > paste xml as classes
4. Profit
xml or json
1 min ago, by Johan Larsson
23 secs ago, by ton.yeung
3 mins ago, by Johan Larsson
1. Copy some xml into clipboard
2. Create a new class in VS, delete everything in it
3. edit > paste special > paste xml as classes
4. Profit
oh you mean:
38 secs ago, by Travis J
1 min ago, by Johan Larsson
23 secs ago, by ton.yeung
3 mins ago, by Johan Larsson
1. Copy some xml into clipboard
2. Create a new class in VS, delete everything in it
3. edit > paste special > paste xml as classes
4. Profit
19:56
That reminds me of
17 secs ago, by ton.yeung
20 secs ago, by NETscape
38 secs ago, by Travis J
1 min ago, by Johan Larsson
23 secs ago, by ton.yeung
3 mins ago, by Johan Larsson
1. Copy some xml into clipboard
2. Create a new class in VS, delete everything in it
3. edit > paste special > paste xml as classes
4. Profit
@TravisJ but did you try it?
@JohanLarsson - What type of structure does the xml need to have?
<hello>
<world />
</hello>
?
dunno, I just grabbed the first xml I found
@TravisJ should work
wow
that is freaking awesome
#he tried it
19:58
the json can do that?
sold
#blogged in chat
how to prevent json from always making class rootobject?
{"blog": { "codingReview":"agreeable", "numbers":[1,2,3,4] } }
unsold
or at least, slightly unsold
you wanted blog?
When you encrypt your app.config do you have to decrypt before you can grab the values out of the configuration?
Yeah I wanted blog
It still makes blog, so I guess always deleting the rootobject class would be required
@ton.yeung - What about nested classes in an array?
{"blog": { "codingReview":"agreeable", "interfaces":[{"name":"me","remark":"hi"},{"name":"me1","remark":"hi1"},{"name":‌​"me2","remark":"hi2"}] } }
Makes a comment class
now to make it hard
it blew up
there was a hidden character
20:10
Hey guys. Can anybody here help me with powerpoint add-ins?
PowerPoint.CustomLayout customLayout = null;
PowerPoint.Slide activeSlide = null;
customLayout = Globals.ThisAddIn.Application.ActivePresentation.SlideMaster.CustomLayouts[7];
activeSlide = Globals.ThisAddIn.Application.ActivePresentation.Slides.AddSlide(Globals.ThisAddIn.Application.ActivePresentation.Slides.Count + 1, customLayout);
PowerPoint.Shape textBox = activeSlide.Shapes.AddTextbox(
Office.MsoTextOrientation.msoTextOrientationHorizontal, 50, 50, 600, 500);
yeah from chat
Pretty interesting stuff
textRange.Paragraphs(1).ParagraphFormat.Bullet.Type = (PpBulletType)(PpNumberedBulletStyle.ppBulletCircleNumWDWhitePlain);

I also tried this but it gives me a value out of range exception
sold : unsold ratio?
@JohanLarsson - 3:2
@TravisJ If you encrypt your app.config section at the machine level, will it impact your code? Will you have to decrypt at all or no?
20:20
@Greg - I am not sure, sounds complicated :P
@TravisJ Trying to make heads or tales of that.
I don't encrypt my web.config at the moment even though it is highly recommended
@TravisJ That is why I was looking at it, but this is for a local service I'm building. Should I potentially just use the DAPI to encrypt? Then store the key in the app.config. That way someone has to be an Administrator and physically be trying to get the data out of it?
Sorry man, I am not sure
@TravisJ Eh, all good. I appreciate the help.
edc
edc
20:39
I haven't seen a whole lot of people encrypting web.config, but maybe because I haven't accessed very very secured systems
Hiiiiidy ho
@TravisJ It looks like the Asp.Net will decrypt it on the fly.
oooooooo Just got the specs of my new Dev machine!
@EvanL whaddya get whaddya get?
20:53
17" Macbook Pro w/ Retina Display, Quad core i7 3.2Ghz with turbo boost, Maxed out RAM (32GB), 1TB SSD, and a 30-inch extension display
Dual Boot to Win8.1 with VS2013 Ultimate + UnityVS
and resharper.
@EvanL Ew, a Mac...
@Greg Yeah, hence the dual boot
each
They build to iOs so they all have macs, but the machine is sweeet
20:54
17" with 30" extension...
@EvanL Kind of cool they give you 32GB memory.
i'd of asked for 2 30's
@NETscape Yeah one thing at a time
@NETscape I've got four 27" Displays...
I can't see 17' macbook pro on apple.com
20:55
i'm jelly
a 17 foot macbook doesn't exist ;)
I don't think they sell the 17" model anymore.
Oh it might be 15", looked like 17" in the picture they sent me
But meh... the 30" display will work fine ;)
They said I can add displays as I need (which will be fast since we use Unity).
If it is new, it will be 15". If it is an older Mac from last year or the year before that the 17" is possible.
The shitty part is they got me one of those tiny mac keyboards without a numpad...
will be bringing my own.
20:57
apple.com does not say anything about 32gb ram either
That is directly from the spec sheet, not sure if its custom or something.
Marcin you are the devil haha
I'm just curious :) 32gb in a laptop is really rare, isn't it?
@MarcinJuraszek I know I'm looking at that too, maybe a typo on the sheet? It would be pretty rare I would think. Just going off what they sent.
they even say Up to 16GB memory upgrade at the bottom of the page
maybe your employer has some special deals :D
20:59
I feel like their are typos.
its 2014, don't act like its not possible.
Eye fiel like the our two
@MarcinJuraszek lol well either way it's still a nice machine. the RAM is probably a typo then. But then again, they do pull some weird shit. For example, they say they get unlimited free Unity 3D licenses because the COO got in good with the developers there lol
:)
yeah, it's really nice, even with 16gb ram
@NETscape Since your being a smart ass, here is the Apple site- the max is 16GB on their page for their current models.
I'm just kidding Greg, damn.
edc
edc
21:01
I envy you if you do get 32GB RAM lol
even my work desktop has only 20
@edc Mine only has 16GB
i have 8! holllllaaa
@NETscape My Ultrabook has 8GB.
edc
edc
16 is plenty :P
I don't do Unity, so it isn't really a big deal.
21:02
Yeah I only think they amp it up because of the graphics aspect of the job.
I find it odd though they have Apple's. I feel like their 3D rendering blows.
@Greg I agree... Some of the artists use PC's, but I think they started as iOS only and just never changed completely over. I do know just about everyone has switched to Dual Boot Win8.1 though lol
@EvanL I kind of wish I had a Surface Pro 3 with the 4K Dock.
I'll know more when I actually get to work there on Tuesday. So i'll see if they were just blowing smoke up my a$$
Sure it is only 8GB memory and 256/512GB SSD but the size and the pen are pretty rad.
21:04
currently using 6.9 of 8 :)
@EvanL are you starting new job on Tuesday?
@MarcinJuraszek Yep
Yeah I'm excited
what made you change job?
21:11
@MarcinJuraszek My current job is a mix of Sysadmin/Software development. Wanted to go pure development in an environment that will help propel my career, and my abilities. I'm the only programmer at my current job, so I feel my learning potential has been reached here.
Not to mention a pretty substantial pay increase.
@NETscape Didn't mean to bite your head off.
Plus the new job is game / robotics development, which will be alot more fun than programming data access and business automation all day.
@MarcinJuraszek @EvanL Can I get your opinion, does this mean it will decrypt transparently throughout the application?
I see. That's really cool.
@Greg I've never used it, so I don't know
@MarcinJuraszek ...
21:13
@Greg It seems that it would work throughout the application if you implement it that way... hard to say without testing it though.
Can you mock up a small page and check it?
Just do a bunch of logging.
@EvanL I'm actually implementing it into a local Windows Service, so if it fails it should surface rather quickly.
@MarcinJuraszek sorry, i know my brb was long as hell, pretty much what i was saying was that async programming in web apps isn't about speeding things up, its about freeing CLR threads
so IIS can use them to serve other requests
"consumers' shift from PCs to mobile devices, as well as a declining printing business and some ill-fated acquisitions" tablets, hp printers suck now, and hp probably shouldn't (but is) buying their way into enterprise planning software
@Steve - lies
why does nobody believe me lmao
@Steve - async allows my webapp to do database interactions at a fraction of the time it would have taken
i'm not saying there aren't cases where it DOES speed things up, i'm saying the primary focus of async programming in web services/web apps is to free up those threads
21:44
how do you free up those threads? speed things up... no?
everyone is right
you offload the io bound work to windows, let its threads handle it, so your CLR threads can be used for other requests
by iis
i've literally read all of this in a book (pro web api), and then got confused and had a 2+ hour conversation in here with reed about it
which i'm shocked nobody remembers
@TravisJ @Steve Isn't that the major point of the next iteration of Asp.Net vNext. To lighten the load and emphasize middleware, so the application can be lighter and more agile. Though Async can speed up your individual application it also is to help free the threads for Internet Information Service to handle page request. The longer those threads are locked, the slower the page. The heavier the page, the slower as well.
the longer those are locked(blocked), the more likely you are to get thread starvation in your clr threadpool, when iis gets a request, it'll have to wait for an open thread, its queue will stack up with requests, when its full, your http stacks (http.sys) queue will fill up, until, in the end, your users just get denied
@Steve - It helps to free up the IO threads. But that is more important in a desktop app than a web app. In the IO thread is locked in a desktop app then the UI is locked. That isn't the case with web.
i'm sorry, but thats completely, 100% wrong.
21:49
Running out of the ability to service a response with IIS is extremely rare even without async.
this part, specifically: But that is more important in a desktop app than a web app.
well, agree to disagree i guess
A desktop application is only servicing one user. IIS is serving thousands.
A desktop application usually does not run with massive hardware support.
yeah, so why would it be more important to free up threads on a desktop application
Because it doesn't have the depth. Your desktop app is not going to be supported by a load bearing network.
so, you're saying i should write shitty code because i think the hardware can handle it?
i'm going to be straight up - not much of a desktop developer, so i can't speak on that side, all i can speak on is the importance of writing scalable code for web applications
21:53
async all the things? It means more on desktop when you are freezing the UI than on web where you are possibly underutilizing hardware.
async is a burden when overused
@TravisJ I think @Steve is attempting to convey that your code and scalability to still be highly optimized is important, as the application grows and it may grow faster then the business scaling the equipment to cater to the influx.
@Steve I agree with @TravisJ on that, Async is a bitch when it is all over the place.
That is a fine broad point to make. However, why is async significant to web applications? It isn't to free up unused resource in IIS. Web applications run without utilizing async behaviors very efficiently
should be used for io bound work, you can watch videos of Scott Hanselman saying "we're not cavemen here, so i'm going to use async await" at conferences.... so can it be overused? absolutely, everything can be overused, but nothing i have said so far is incorrect, and i'm shocked that i'm getting so much resistance from this
and on that note, i'm done debating
It is a semantic argument that you are making.
@TravisJ I found async/await is useful for many things, but often you genuinely do need to wait for something to finish...
21:57
"async is better for I/O than for speed" is the issue that I disagree with.
@Pheonixblade9 - Yeah that is true. But it is best to only have to wait on the thing that is taking the longest than to wait for every thing in the sequence one at a time.
quote: No matter whether the operation is performed asynchronously or not, the user has to wait for the same amount of time to see the result. Though you may well think that this makes asynchrony undesirable for server applications, you would be wrong.
Apress Pro Web API chapter 2, 2nd page in chapter
If the time spent waiting is less than 50 milliseconds there is no point in using asynchronous approaches.

« first day (1314 days earlier)      last day (3860 days later) »