« first day (2139 days earlier)      last day (2810 days later) » 

War
4:00 PM
yes but that may be null because the task aint complete yet
 
no lol
 
how would I convert this input type:
<input type="submit" value="Create" class="btn btn-default"/>
 
it waits for the task to complete
 
War
im asking for the result before the execution is done
 
into an actionlist like this
@Html.ActionLink("Create Review", "Index", "Reviews", null, new { type = "submit"})
in that format
 
4:01 PM
var result = task.Result;
is the same as
task.Wait();
var result = task.Result;
 
War
@MooseTheTitan seems fine ... whats the problem ?
@KendallFrey no it isn't
 
Yes it is
 
War
then they must have changed something very recently
 
I want to convert the <input type="submit"> into an actionlink format
 
@War Nope, I'm pretty sure it was always like that
 
War
4:02 PM
I have code that doesn't always work when just using task.Result
 
having an actionlist on my form in razor instead of the input type="submit
 
The original documentation says the same thing
 
War
the problem is execution order ... tasks that you don't wait on are not waited for so the next line will execute in the current method
 
If you've had 10 conversations with the guy giving him false information, I feel bad for him.
 
War
the fact is ... code written this way is causing bugs
waiting on the task fixes it
 
4:04 PM
posted on August 24, 2016 by Phil Haack

Last week my family and I went on a cruise to Alaska with four other families and we didn’t die. Not that we should expect to die on a cruise, but being confined with a bunch of kids on a giant hunk of steel has a way of making one consider one’s mortality.

 
When you say waiting, do you mean awaiting?
 
War
yes
 
That's probably to do with sync vs async
 
War
I said I was talking about async code at the start
 
We've obviously been talking about async code the whole way
But using .Result makes async code behave as if it were sync
await doesn't
 
War
4:06 PM
I'm in a async method async calling another method and not waiting on it's result, just expecting it to be there
.Result doesn't automatically wait
 
It does
It sure does
It really does
 
War
then how come it cases bugs?
 
2 mins ago, by Kendall Frey
That's probably to do with sync vs async
 
War
var result = SomeAsyncCall(0.Result; <--- should never return null in this context
 
Yep, it does.
Kendall is correct
Calling .Result blocks
 
4:19 PM
@War Only if the task never completes with a null result
 
War
it doesn't
i've been able to reproduce it too
 
Well, demonstrate
 
It does block War.
 
War
token = AutheticateUser(user.Email, Login1.Password).Result;
if (string.IsNullOrEmpty(token))
{
    var regTask = RegisterUser(user.Email, Login1.Password);
    regTask.Wait();

    token = AutheticateUser(user.Email, Login1.Password).Result;
}
Session["token"] = token;
Session["user"] = user;
all method calls here are async tasks that can never return null
i have been able to break this by adding a small to medium amount of load to the server
 
What is "breaking it"?
 
War
4:33 PM
Session["token"] = token;
Session["user"] = user;
those two lines should never put null in session
the funny thing is ... the null check here is pointless
 
why?
 
War
token is never null
 
what about the empty string?
 
War
the method in question either returns the user token or an error (by throwing an exception)
 
What happens if you remove the entire if block?
 
War
4:37 PM
No idea ... not been bothered to fuck about with this code ... just told the guy to fix the bugs reported in it by our test team
 
Yeah well don't go telling people false information
 
War
lol sure
@KendallFrey @RoelvanUden this is probably the issue: blog.stephencleary.com/2012/07/dont-block-on-async-code.html
some weird shit around blocking or something causing the server to do something odd with the session perhaps ... if that's the case ... I am probably wrong and maybe just my understanding of task.Result needs updating
 
@War I thought you said it was returning null. That's very different than a deadlock.
 
War
I'm sure I read somewhere about not using task.Result as it causes async problems though
@KendallFrey the method being called isn't returning null
the code block ends up with the session var being null
two very different things
 
No, that's not very different
you're assigning the session var the result of the method call
so if the task isn't returning null, then everything you've said up until now has been irrelevant
 
War
4:47 PM
Session["foo"] = something;
var result = Session["foo"];
what is result ? ... is there ever any chance it will be null if something is never null?
 
As I said, I don't know ASP.NET
 
War
if I step through the code I can see the value returned from the call that populates something
 
But if that does happen, there's no reason to suspect tasks
 
War
then on the next line the session var is null
the problem I found was to do with using tasks in this way ... maybe Microsoft fixed a bug in it or something at some point
but I've always not used it this way ... perhaps it wasn't tasks, maybe it was something to do with session, I don't know but I have been able to find and reproduce this problem
the fix has always been, dont, in async method, make an async call then just do .Result and stuff that in to session because as I said before "it might not be there yet" when you want it on the next line
 
but did you try to debug the problem by elimination?
 
War
4:50 PM
I can't recall where I got that from but it works
that "rule" fixes the problem when I have code that looks like the above
when I first hit the problem I went through all sorts of shit, including the MSDN docs on how tasks should work so no doubt saw that thing about result and probably thought what you guys are telling
 
@War It's like Newtonian gravity. It works in some situations, but don't preach it as gospel because we know for a fact that there are plenty of situations where it doesn't.
 
War
sure ... just not seen a situation where it doesn't ... show me one and maybe I can review my thinking
It's probably some dumb shit to do with specifically some old version of webforms and .Net 3.5 and session state and then caching settings or something crappy like that
but the fact is ... writing the task code differently fixes it
Generally speaking I thought it was good practice to use a continuation anyway
 
@War Something simple like var answer = Task.Delay(1000).ContinueWith(_ => 42).Result;
@War It is, using Result is a terrible idea unless you specifically want synchronous code for a very good reason.
 
War
no i meant, use the result of the task in a continuation
since the general rule that I am hearing is "if using async, do it all the way down the stack" be async all the way
not just for some of it
anyway gotta go
later
 
@War Yes, that's normally what you do with a continuation...?
 
5:06 PM
Kaitlin Pike on August 24, 2016
Welcome to episode #72 of the Stack Exchange Podcast, recorded Tuesday, August 2 at our headquarters in NYC.
 
5:25 PM
Hello guys (and girls), do you have a recommended DI container for C#?
 
5:38 PM
Unity?
 
looks promising, thanks
I guess my Google-fu is weak today
 
5:53 PM
no worries
i've used unity and windsor something
unity felt a lot sleeker
why's sql server gotta be retarded?
 
user47589
6:17 PM
because reasons
 
user47589
My preferred IoC container is Autofac.
 
user47589
Also because reasons.
 
lol
hey Amy
apparently SQL CLR is incapable of handling utf 8
 
user47589
6:39 PM
are you sure?
 
user47589
what version of sql server? 2008 doesn't support UTF-8
 
Hello,
Could you please tell me what that empty block near set means? I haven't seen this thing yet. Is this is just an "auto-set"?
public string FullName { get { return string.Format("{0} {1}", FirstName, LastName); } set { } }
I know properties ofcourse, just haven't seen set{} yet
 
user47589
its an empty setter
 
user47589
its just a setter that does nothing with the set value.
 
Thank you.
 
6:49 PM
That's a real weird way of making something readonly
 
user47589
agree. i'd go further and say its a bad way of making a property readonly
 
Reflection can still set it
 
@Amy this seems to produce nicer looking code after probably-not-enough playing with it
tnx
 
War
@DaveRandom I use ninject in case you're still looking
 
ugh, more options :-P
will take a look at it tomorrow, tnx
autofac is winning atm
 
War
6:56 PM
if i wasn't using ninject i would probably use autofac
heard it's often faster
@Yoda oh dear ... someone really hates that code lol
 
I don't care much about speed, this is a winforms app and while a bunch of reflection for a DiC will probably give me a perf hit at startup, it's only at startup so I don't care. Plus legacy app is legacy.
 
It's from WCF-jumpstart from pluralsight
that empty set
 
War
jeez
no wonder people out there arent writing good code ... even the training sites teach total tripe
@DaveRandom that's how I look at ninject ... yeh it may be slower but its only on app load
I just like the api
 
His code annoys me, but I somehow need to get through it,. Scott Allen's courses are nice. Ok, going back to work.
 
War
@Yoda is your real name Matt?
 
7:00 PM
Nope.
 
War
hmmm my cousin used to use the name Yoda when he created accounts for stuff
thought you might be him lol
 
@DaveRandom I am physically pained by reading this
 
@War - Most people writing code don't understand the underlying language agnostic theories associated with it.
 
user6096770
does anyone know or have a guess what cpu's ms azure uses for their web app service options?
 
War
@FluffyWuffy xeons mostly
 
user6096770
7:02 PM
what models?
 
War
they run large banks of multi zeon server racks I believe
@FluffyWuffy it likely varies
 
user6096770
yeah
 
War
it's unlikely that all servers for something as big as a datacenter are all identical
 
user6096770
hey i want to push my cpu % in my web app
 
War
i'd be surprised if anyone knew the full details other than perhaps one or two people that actually run each data center
 
user6096770
7:04 PM
what math function can do that?
 
War
I know perlin noise craps all over cpu's
I've been using the gpu because of it
 
user6096770
oh
 
user6096770
with gamers, they use programs like prime95 to push their cpu to 100% to test overclocking
 
user6096770
is there something similar to test host providers cpu?
 
user6096770
i tried this and the %cpu was like 0.1, public double math()
{
return 5*5*(Math.Pow(2, 31));
}
 
7:07 PM
Do you know what prime95 does?
 
@FluffyWuffy That's trivially simple code, it will finish in no time
 
user6096770
il google for a better one
 
Protip - don't watch that video. You fall into a depressing hole of nostalgia
 
@War - The azure server farms are basically train cars that are stacked in unassuming warehouses. There is bound to be some difference per container as hardware develops and is phased out.
 
War
7:09 PM
@TravisJ yeh that's my understanding
 
@FluffyWuffy a better what?
 
War
each container might be full of the same machine builds but there would be many in a data center
 
Right
 
War
Google famously offered to provide a container as a product
there was some stuff about it
 
user6096770
@KendallFrey a better method that runs on my web app, so i can click on it on a browser and push the servers CPU, i want to find out it's limits
 
7:12 PM
100% is the limit. I guarantee it.
 
user6096770
@KendallFrey then i want to use that same function and create a console app and test how my PC handles that function
 
War
@FluffyWuffy you'll likely never know the limits of the host cpu as the machine is likely virtual and limited by the vm host
unless you pay a crap ton for hosting
 
user6096770
so i get an idea of what kind of power my web app has in ms azure 'shared' subscription
 
War
but azure is all virtual
 
@FluffyWuffy Sounds like a big waste of your time. What are you trying to accomplish by doing this?
 
War
7:14 PM
@FluffyWuffy the funny thing is that azure is set to scale out as needed so it'll push harder and harder then they will bill you for the compute power used
 
user6096770
if they bill you for compute power, i have to make my website efficient then, wouldnt it be competent to see what that is?
 
user6096770
obviously in programming theres many ways to do 1 thing, but few ways to do it the most efficient, so i want a little function that will push ms azures web cpu so i can get an idea of how to code my website
 
@FluffyWuffy Something doesn't make sense there
 
Oh. Okay. while(true) i = i >= int.MaxValue ? int.MinValue : i + 1;
It tells you nothing though, but have fun brah.
 
@FluffyWuffy - Two words. Time complexity.
 
7:17 PM
Racking up high CPU usage on an azure server won't tell you anything about how to write efficient code
 
^
Making sure that your most inefficient algorithm is running faster than o(2^n) is enough to ensure that your code will be efficient 99% of the time.
 
user6096770
ah
 
user6096770
i guess im being over-concerned about this
 
Websites tend to fail at efficiency from using excessively large images, loading ads that use while loops to block the page, and downloading far too much information from database tables (select *).
 
user6096770
hmm so now my question is.. why would anyone select a premium tier with like '4' cores in ms azure?
 
user6096770
7:28 PM
what kind of web app needs 4 cores?
 
@FluffyWuffy a high traffic one
especially if it is abnormally CPU-bound
 
user6096770
100k users/day?
 
I can't give you a number
 
War
@FluffyWuffy an MMO game server
 
7:55 PM
Guys I have a linq query, do you guys think it needs some optimization?
var results = context.FinancialTransactions
.Where(x.StudentKey != null)
.GroupBy(x => x.StudentKey)
.Select(x =>
new SomeViewModel
{
StudentKey = x.FirstOrDefault().Student.StudentKey,
StudentName = x.FirstOrDefault().Student.StudentName,
StudentId = x.FirstOrDefault().Student.StudentId,
DuesPaid = x.Sum(s => s.AmountSubmitted),
EachStudentTransactions = x.Count()
});
 
War
that may raise exceptions
you're not null checking after those FirstOrDefault() calls
 
@Obviously Can't you group on student instead of student key?
 
I can, should I?
 
It sure looks like it
 
War
@KendallFrey i read from that, that there could be many students with the same student key
 
7:58 PM
You're basically duplicating the student
 
I dont like the fact that i have to do x.FirstOrDefault().Student. for each property
 
@War That seems unlikely, and a bad idea
 
no there will be only one student with one student key
 
@Obviously Hence my suggestion
 
how to get rid of doing x.FirstOrDefault().Student. each time, i want to populate a property
 
War
7:59 PM
so its all financial transactions grouped by student (the intention)
 
thats a lot of x.FirstOrDefault().Student.
 
War
could you not query the other way
 
@Obviously ...group by .Student
 
user47589
obviously
 
Ok I change it, to gropu by student
but still I have to do x.FirstOrDefault().Student. in the select
Oh got it,
I can do x.Key. and then i can see those properties
 
8:01 PM
You probably don't even need to select those properties individually
 
thats my updated query
var results = context.FinancialTransactions
.Where(x.StudentKey != null)
.GroupBy(x => x.Student)
.Select(x =>
new SomeViewModel
{
StudentKey = x.Key.StudentKey,
StudentName = x.Key.StudentName,
StudentId = x.Key.StudentId,
DuesPaid = x.Sum(s => s.AmountSubmitted),
EachStudentTransactions = x.Count()
});
@KendallFrey what do you mean?
 
Just put the entire student in your viewmodel
 
No I need to populate the viewmodel
 
War
var result = context.Students
   .Where(s => s.FinancialTransations.Any())
   .Select(s => new { s.Key, s.Name, s.Id, s.FinancialTransactions.Sum(t => t.AmountSubmitted), s.FinancialTransactions.Count() });
would that not work?
obv I shortened it
 
Yeah I guess It will
What is optimum?
 
8:06 PM
@Obviously best is subjective and depends on everything
 
Anyone encountered unable to connect to remote server... unable to remotely debug error in VS?
 
That's the one where you're debugging 64-bit, right?
 
maybe? lol
I think it's related to IIS
How do I configure my IIS application pool?
 
@War yes, your query is considerably faster
Like really fast
thanks guys
 
War
8:31 PM
Of course it is ... Run both and profile them
 
8:49 PM
@TravisJ apparently they don't open the containers until they accumulate a certain number of hardware failures then they just scrap the whole unit
and they have versions that contain built-in gensets and power transformers
so you can just order one and set it down in the middle of nowhere if that's what you need
 
@TomW - I wouldn't mind getting that scrap :)
 
You can genuinely buy a Microsoft-branded server rack, preinstalled with all the bits to run a mini datacentre, and a Microsoft-branded lorry shows up at your office and installs it for you
 
Sounds affordable
 
no worse than paying for IaaS of the same scale to run the same stuff
 
At the point where most places need server racks they usually in house it.
 
8:56 PM
True enough, but having the thing just show up working saves you a bunch of time, I guess
and your developers can write the same code, and putting it on Azure or on your own racks doesn't matter
I dunno, I don't know of anybody who's actually done that
 
From a company standpoint, it is probably far cheaper and better for maintenance to have some staff around capable of building these on site.
 
Predictable load that changes more slowly than your own infrastructure team can build out new metal is a good candidate for in-house, everything else, yes it's more expensive in running costs, often considerably so, but consider time to market - whatever your developers haven't yet made up their minds what they need for, it's just there
 
Yeah, planning becomes very important.
 
"It's expensive" - yes but how long are you going to be running it for?
How long before infrastructure can set up enough servers to run [brand new thing devs have just invented] and get it fully stable and weed out the bugs? How long before the developers actually decide it's crap and they want something else?
 
Foreva :D
I suppose it also depends on which industry you are talking about. Banking or gaming? Yeah, the reliability of msft is nice. Entertainment or business? Things become a lot less dependent on "fully stable" and a lot more dependent on "does what it is supposed to".
 
9:04 PM
Entertainment is where they put out a few good examples of things that need to be spun up fast then thrown away
Well, media
I'm not sure where you'd categorise that
e.g. sentiment analysis of the U.S. primaries
they used Event Hubs for that IIRC
But maybe it's something like the voting model for a new reality TV show
If your genomics project is going to be doing HPC for the next decade then sure use the cloud to get started until either your computing PhDs finish building your cluster or you run out of money
 
Hiya
 
9:20 PM
o/
 
9:53 PM
I am trying to create custom logger
for example I call it Logger.Log(this, "Some custom message" , Severity.Info)
Is there any way for me to get calling function name from this parameter?
It is getting called from public function
 
Only thing I can think of off the top of my head is examine the current call stack
 
hmm, this looks a good step to what I want to see
thanks
 
No problem
 
There is the nameof() operator, isn't there?
 
I think the thing is that at this point he doesn't have anything to call nameOf on
 
9:58 PM
oh. point
 
There's the class but he wants the method
I think.
 
feature request for C# 7
 
I am in 2.0 lol
legacy app
to debug :)
webforms ftw!
 
....by the Emperor
 
You have my condolences.
May Talos have mercy on your soil.
 
10:02 PM
There is a way to use attributes to do what you want to do @Teomanshipahi
 
Attributes for logging?
 
But did you say 2.0....as in .NET 2.0?
If so you are fawked then
And not having the calling member name is the least of your problems :p
I'm pissed off enough about .NET 3.5 holding back my project
Let alone .NET 2.0 :p
 
shooot, I cannot use this for 2.0? :(
 
Nope, 4.5 only
 
I already copied to code and ready to paste :O
 
10:07 PM
You shouldn't be surprised...you can't do jack shit with 2.0
In fact it's not even supported by Microsoft anymore
 
Yeah, app will die soon. I am working on caching module to keep it offline.
and I will bury it with my hands.
I will stick with StackTrace for now. at least it gives me what I need.
 
That's your only choice
Now I really wish they'd end support for .NET 3.5 :D Then everybody can focus on .NET standard
 
@borrrden It's still supported to an extent. Too many enterprise Apps still run 2.0
 
Which is?
It's not
It was end of lifed in April of this year
 
my last job (Government of Canada - Health) ran all health servers with .NET 2.0 applications. Over 10million LOC, and we got extended support from MS.
 
10:18 PM
Although that might just be the original 2.0
And not 2.0 SP2
 
We were in the process of upgrading it to .net 4.5, but many enterprises pay microsoft millions of $ for extended support
But yea, it's toast for the regular world, good riddance.
 
Support for .NET Framework 2.0 ended on April 12, 2016.
That's what's written
But then in 2.0 SP2 there is no end date written so who knows what is going on
Anything is supported for the right price I guess
 
@borrrden So true it is
 
I don't think I've ever used 2.0 seriously
Maybe I'm too young and innocent at 31 :p
 
I'm 35. Started in 2001 with .net
Young is those that are 20 using .net and acting all entitled
 
10:29 PM
30. Started 2008 with some old shit on 2.0 being moved
 
10:42 PM
I started in 2007 or around there
But it was mostly XNA and Unity3D because I was a digital media major
Before that it was all C++ and C
 
11:38 PM
Hmmm I guess my time zone is not great for interaction with others lol
 

« first day (2139 days earlier)      last day (2810 days later) »