« first day (3342 days earlier)      last day (1589 days later) » 

1:42 AM
So I changed the target for an Eto.Forms project from .net Standard 1.6 to .net Standard 2.0 and apparently I can't hit breakpoints in one file of the same .csproj, but I can hit them in the other file. And Debugger.Launch and Debugger.Break don't work either.
That was working beforehand
File A is in a different namespace than file B in the same project. I can breakpoint file A just fine. File A calls something in file B, which I can't debug into or breakpoint or anything. Like it's not in the .pdb at all or something, it's ridiculous. Any ideas?
 
2:05 AM
pdb file must be generating totally corrupt because I'm always hitting a function that isn't called from anywhere at all (as in, ctrl+shift+F guaranteed not called in the solution). All files are saved, so it's not pending changes. Huh
 
 
3 hours later…
4:45 AM
Recreated solution project and migrated existing files, problem solved now.
 
5:38 AM
Ben Popper on December 10, 2019

This week we chat with Chris Dixon, a general partner at Andreessen Horowitz, where he helps lead its Crypto Fund. Dixon and a16Z are now launching a new Crypto Sartup School devoted to educating young developers and entrepreneurs interested in the crypto space.

You can check out the back story of Dixon’s first company, SiteAdvisor, here. It was built during a time when spyware was a booming business and browsers had few systems in place to combat bad actors. The company was acquired by McAfee in 2006. It’s a great trip through the history of web security at the time. …

 
6:28 AM
> If you have a line of 100 rabbits in a row and 99 of them take 1 step backwards, what do you have?
 
mr5
yes
 
6:40 AM
Buenos dias CeSharp!
 
7:13 AM
@CopperKettle hare-line fracture?
 
7:24 AM
@CopperKettle a particularly harey situation?
 
how to send any file to a network printing from c# server side code?
 
if I'm not mistaken, you can write to the network printer like you would a file
and assuming it's the proper format, the printer knows what to do with it
 
can you please explain more
 
1) Get the path
2) File.WriteAllText
3) ???
4) Printed
 
Goood morning.
 
7:35 AM
Hola Avner
 
@Speedy If you know how to write to a file, then you also know how to print something
 
"???" == printer magic
 
again, provided you're providing an image or pdf or something
 
Three weeks to go. Today we'll mess around with ASP.NET core routing and see if we can have some magic attributes that automatically maps several different route templates at once.
 
I have a PDF file on server, where an API is hosted on IIS, now I have a network printer somewhere in the world, the c# code should send the PDF to that printer and the printing should be done
 
7:38 AM
@Speedy What protocol does that network printer support?
 
"???" = this is what I am looking
 
Morning.
 
mr5
@AvnerShahar-Kashtan Google uses ASP?
 
@AvnerShahar-Kashtan there no specific printer it can be any
 
how does the user specify which printer to use?
 
7:47 AM
there would be multiple users, they will specify the IP, printer name etc
 
@mr5 Check out my starred comment on the board ------>
 
generally you specify a printer with a network path like \\SOMEDOMAIN\PRINTER1
you would attempt to write to that address as if that were the name of a file
of course if the server doesn't have access to that printer, it won't work
 
@Neil I'm not sure that really works for anything except for plain text files.
 
@AvnerShahar-Kashtan well it has been a while admittedly
 
mr5
lucky avnir
Do you think employees in Google are allowed to take pictures inside of the office?
 
7:54 AM
@Neil thanks, if there is any code reference it would be great
 
mr5
oh yeah they are
^ avnir after 1 month
 
@Speedy this is what I did in Java to write to a printer :)
I wouldn't know how to do the same in C#, but I'm sure it's just as straightforward as writing to a file
 
Ok, will try this thanks
 
@mr5 Sure, why not? As long as there isn't any IP prominently displayed.
 
"Oops, accidentally took a photo containing the monitor of a network administrator and all of his many many passwords in plain text.. How clumsy of me.."
 
mr5
8:03 AM
does the StreamReader gets disposed prematurely if I add using var reader = ...?
cuz if I do, I always get an empty string
 
Hello guys, isn't better to use struct when developing asp.net application for incoming request and outgiong response instead of using class ?
 
mr5
@Neil one day we can trick avnir to do that for us.
@Kob_24 better at which part?
 
by doing that we only use the stack instead of usng the heap
@mr5 i mean for performance
since the class is not doing much than parsing the object
and maybe more cleaner code
 
@mr5 No, it doesn't get disposed ever. Which is a different bad thing.
 
ohayou
 
8:08 AM
@mr5 Yes, it is.
Because using var reader is disposed when the method goes out of scope, but because the method returned an incomplete task, rather than a string, it's possible that it'll be disposed before the task completes.
@Kob_24 It makes sense in some places. Not in others. There's no clear cut "always use X".
In fact, the common guideline is "use a class unless you know for sure that a struct will be better".
 
mr5
@AvnerShahar-Kashtan I'm thinking I could fix this using a temporary variable?
 
"Use the stack instead of the heap" doesn't necessarily mean performance. A struct's value is copied whenever you pass it to a method. If your struct is a 5k JSON payload, that's a lot of copying.
@mr5 You can do it by awaiting inside the method rather than returning the inner task.
 
@mr5 Oh, I misunderstood. Just use using var reader ... and return await reader.ReadToEndAsync()
 
private static async Task<string> StreamToString(Stream stream)
{
    using var reader = new StreamReader(stream);
    return await reader.ReadToEndAsync();
}
 
mr5
yep. this is one of the gotchas when trying to avoid async/await in the body declaration
 
8:12 AM
In your version of the code, the method gets a task from the StreamReader, returns that task to the caller, and ends - it's served its purpose, it doesn't exist anymore.
 
The fact that structs are value types affects performance, though
depending on how you use your struct, this can be good or bad. On the
positive side, allocating memory for structs is very fast because this
takes place inline or on the stack. The same is true when they go out of
scope. Structs are cleaned up quickly and don’t need to wait on
garbage collection. On the negative side, whenever you pass a struct as
a parameter or assign a struct to another struct (as in A = B, where A
and B are structs), the full contents of the struct are copied, whereas
 
In the second version, the method starts an async call to StreamReader, returns a different task to the caller, essentially telling the caller "I'm handling it, I'll let you know when it's done", and when it's done, it completes the task, returns the value, and then exits completely, thus triggering the dispose operation.
 
@mr5 Why would you want to avoid async/await?
 
@mr5 There are other aspects to it as well. Your method has sync elements (create the StreamReader) and async elements (read to end). When you're eliding the await call, an except on the sync side will have a completely different stack trace than one on the async side. Async/await lets you have a coherent stack trace.
 
^ This is reason #1 to always use async/await; stack tracing makes sense.
 
8:15 AM
As always, Stephen Cleary's blog is insightful. It's important to check, though, if some of the performance improvements he refers to are still relevant: blog.stephencleary.com/2016/12/eliding-async-await.html
 
mr5
@RoelvanUden I always like to do it in the caller
so to minimize await calls
 
Why? Performance? It doesn't matter.
 
The first pitfall he mentiones is exactly your premature disposal scenario, @mr5.
 
mr5
 
if you can literally do nothing before some async task is finished, you can and should await for that task to finish
 
8:16 AM
@mr5 Not "because C#", because EVERY LANGUAGE.
That's the only way it makes sense to do it.
 
> It’s more efficient to elide async and await. By not including these keywords, the compiler can skip generating the async state machine. [..] However, it’s important to point out that each of these gains are absolutely minimal [..] The vast majority of the time, async is dealing with I/O, which completely dwarfs any performance gains
> When I started writing about async, I would always recommend eliding async and await, but I’ve modified that stand in recent years. There are just too many pitfalls to recommend eliding as a default decision. These days I recommend keeping the async and await keywords around except for a few scenarios, because of the drawbacks described in the rest of this blog post.
 
why would they say it dwarfs any performance gains if it is I/O? Some of the biggest wait times in programs comes from waiting for something to read/write to the disk
 
mr5
so if you were to taught a newbie C#, you would recommend: don't return a Task<T>, immediately return the T cuz it will cause you trouble
 
I wouldn't use async keyword unless it were legit being used asynchronously
 
@Neil Exactly. @mr5's method probably spends 99.9% of its time doing I/O. So the overhead of the inner await call is marginal compared to the overall method's runtime.
@Neil It is - it's calling ReadToEndAsync, which already returns a Task. The question here is whether you're returning that task, or another task that the async/await state machine creates for you.
 
8:21 AM
@mr5 For them newbies, I'd say: If you work with a Task, await it. If that means your method is going to be async, so be it.
 
If you're returning a Task, you're already an async method. The question is whether you use the await semantics or not.
 
You can also choose to not make it a async method though
 
@Neil But we're talking about that specific async method, and whether we want to have the inner task wrapped in the async/await-generated task.
 
if it is never getting called without using await, then why use async keyword unless it were say a library API method?
@AvnerShahar-Kashtan ok, but say you want to connect to a database which is native async. You're never going to call the method to connect to the database asynchronously, because you need the connection before you can do anything else
So at that point, why make such a method with async keyword?
 
@Neil What do you mean by native async?
 
8:23 AM
@AvnerShahar-Kashtan like it is the framework that you're calling. It is a method which is potentially going to take time to perform, so it is declared async
a method you cannot rewrite which can only be called asynchronously
 
@Neil Not sure I understand. If my DB client software has a Task ConnectAsync() method, but I always need to await it before starting a query, right?
 
Suppose you're writing a wrapper for that ConnectAsync() method..
 
GoOoOoOoOoOoOoOoOoOoOoOd Mornin' pleberinos!
 
Say, after you get the connection, you set some other parameters first before returning it to the caller
If you, the caller, never need to be calling that asynchronously, why wouldn't you coerce to a normal method?
it sounds like there's a small bit of overhead at that
 
@Neil No, I think you're missing the point. I will always be calling it asynchronously, because the connection will complete asynchronously.
 
8:27 AM
And you will always be awaiting your call to ConnectAsync..
 
MyConnection Connect(string connString)
{
     var conn = new MyConnection(connString);
     conn.OpenAsync();
     conn.SetParameter(blah);
     return conn;
}
 
I'm referring to the wrapper method of such a call
 
This method makes no sense - I need to await OpenAsync to set a property.
 
OpenAsync would return a task would it not?
it may not be open when you set the parameter
 
@Neil Yes, it would.
 
8:28 AM
suppy sup! :)
 
It needs to be Task<MyConnection>, await OpenAsync(), and then return the connection.
@Neil Exactly. So I need to await it.
Task<MyConnection> Connect(string connString)
{
     var conn = new MyConnection(connString);
     await conn.OpenAsync();
     conn.SetParameter(blah);
     return conn;
}
 
Right. So you await conn.OpenAsync. What you don't do is return a Task
 
@Neil But that's not how async methods work. What happens when the await is called?
 
My point is this.. if you need MyConnection instance now, why bother making the Connect method asynchronous?
it seems to offer you the possibility of running something asynchronously or synchronously if you should decide to await it.. if you will always await the result, why make it return a task ever?
 
@Neil Because that's how the async stack works. When you hit the await, the thread running Connect relinquishes control. That's the point of the await, otherwise you would just do conn.OpenAsync().Wait() and block the thread. But if it relinquishes control, how does the code that calls Connect handle it?
@Neil Because you don't want to block a thread waiting. That's the core of it.
 
8:32 AM
sigh, I'm not really explaining myself then
 
void DoTheThing()
{
      var conn = Connect(); // has to complete first.
      var data = conn.Query(blah);
}
vs.
async Task DoTheThing()
{
      var conn = await ConnectAsync(); // still has to complete first.
      var data = conn.Query(blah);
}
You're asking what's the point of the second thing, if I have to await it anyway?
 
Oh I know this
 
!~translate bueno dias
 
the method that calls DoTheThing won't wait :)
 
Good day
·from Spanish
·with a correction: bueno [días]
 
8:37 AM
the control moves forward from where it was called :D
 
good morning
 
I thot it was german
 
@nyconing wat no, nooooooooo!
 
there's a point when you must resolve all async calls.. if you intend for the call to always resolve right away, there is literally no point to returning a Task
 
mr5
I don't think you would normally use async/await when you're doing web services, but in a platform where there's a UI and it's properly separated from the other operation, you would benefit a lot by not freezing the UI and ruining the UX
 
8:37 AM
2nd correction> Buenos días
 
mr5
Buenos tacos toritillas
 
You may still have to deal with tasks because again, what you call returns a task, but you can resolve that yourself
 
@Neil But that's if you're only thinking of your own execution branch. Imagine this DoTheThing method is the top level of an incoming request. It doesn't matter, you say, if we resolve the async anywhere, because at some point we'll reach this method and be forced to wait, right?
 
I'd think it smarter to make something return a task only if you intend to take advantage of the fact that it is a task and not the object instance in question
 
But it does matter, because when you bubble the async all the way up, you're never blocking a thread waiting for it to resolve. You're always relinquishing a thread whenever there's I/O and letting the async/await resume on a thread when it's available. When you've got a couple of dozen concurrent requests, blocking a thread on an I/O operation can be meaningful.
 
8:40 AM
If you're the only one calling DoTheThing, then you would know if you need it now or later
 
isn't the whole point of async to keep our app responsive!
 
mr5
@HéctorÁlvarez oh shit I just realize that. Avnir would have a power to expose us to our horrendous searches... So everyone, it's time to behave.
 
It's fine and good not to block the thread when that thread can do something meaningful
when it can't, because you need it now, why add that overhead anyway?
 
With backend code, your thread can always do something meaningful. Anywhere you block a thread is somewhere you'll curse when you get a little bit more traffic.
 
I understand the point of async/await. This isn't a misunderstanding of how threads and concurrency works. It's simply a matter of making something async only when you intend on calling it asynchronously
 
8:42 AM
And for client-side code, blocking the UI thread can be devastating too.
 
agree with Neil, he is saying for small use there is no point
if we are the only one using our app
 
@Neil Exactly, but the point is that any operation the resolves eventually to an I/O call should be done asynchronously, because the overhead is negligible and the pitfalls huge.
 
If you use JS you don't have to worry about threads rejoining and blocking and whatnot!
/usefulinfo
 
@AvnerShahar-Kashtan and you wouldn't do it for a UI thread.. but it is situational
 
kinder bueno
3
 
8:44 AM
@mr5 ?
 
isn't it now a norm to use async await everywhere!? :)
 
@AvnerShahar-Kashtan I honestly have to admit I love, love, love, LOVE, not having to worry about threads
 
there must have at lease one thread
 
admittedly, to a layman hearing about strings and threads and not having anything to do with one another must be rather confusing
we've never been good at naming things
 
8:46 AM
haha nice point! :D
it's a good practice to use the async version of methods right?
even if I am making a small app that reads a file?
 
mr5
 
@Neil you are going to say no?
 
@Shad no
 
but avener will say yes
because I/O operation! :P
 
mr5
@RoelvanUden avnir would probably have an access to all of our Google searches
 
8:47 AM
@Shad I was joking actually. :P
If you're not sure, async is probably best
 
not sure about what? I am speaking what you were saying
"If you're the only one calling DoTheThing, then you would know if you need it now or later"
 
if it is a connection to a database, and the thread making this request isn't a UI thread and it's dedicated to loading information from the database, it makes sense that it would simply block
 
indeed
 
it simply cannot go forward without a connection to the database
then I wouldn't make it async, because you'd only call it using await anyway
 
Agree! :D
 
8:50 AM
the day that changes and you can do something else with that thread, you accept a Task for getting the connection and then you do something else in the meantime
but that probably won't be the case
 
makes senseee
 
lets say if you were seeing the code after 2 years and you saw the method as async, you'd assume it were being called asynchronously
 
totally
 
if you wanted to remove the async keyword, there'd be a lot more checking and verification
it's easier to add an async keyword than it is to remove it
 
yes because it can return a void as well! :D
 
8:53 AM
I think 3-4 years from now, more and more APIs will be async by default.
 
^Yes the power of parallel programming!
 
it makes sense for an API, since you don't know how it will be called or how it will be used
 
@Neil Everything is an API. When my controller's code calls a business logic component, that BL component is an API, as far as I'm concerned.
 
haha true true
all my methods are APIs
 
@AvnerShahar-Kashtan if I truly believed that, I'd make an interface class for every one of my classes
that's clearly not the case :P
 
8:54 AM
lolol
 
mr5
make everything async
even variable assignment
int i = await 5
 
HAHAHAHA
 
Task<int> = await 5
 
async using System;
 
mr5
5 is probably at 4 hence we need to await
remember the CPU might not keep up so better to await
 
8:56 AM
async class Helper
 
in scala, you can make everything "async", but it's a bit more elegant
 
@mr5 I don't use Google search so I don't particularly care :-D
 
@Neil It's a question of tradeoffs. Overheads vs. potential gains. Back when .NET (And java before it) came out, native developers said the overhead of a managed runtime is too big to use it for everything, so just use it in the places where it made sense. But the overhead these days is small enough, and machines fast enough, that the tables have turned, and I would now use a managed language as the default, and fall back to native code where I need the extra performance.
 
waiting for object creation you can move on
 
nothing gets called which isn't strictly necessary to fulfill the request
if done right at least
 
8:57 AM
The same thing here. Having all method calls be async has an overhead, and you say "only do it when you really need it". Wait a couple more years and it'll be the other way around, and you'll use "raw calls" when you need to squeeze some more perf, but not as the default.
 
@AvnerShahar-Kashtan fair enough. I wouldn't do it also for code clarity reasons
 
super cool
 
@Neil That's just syntax, though. That will evolve to clear that up as well.
Or use Wietlang. *shrug*.
 
If it isn't async, it is because when I call it I need it at that moment, and there can be no doubt of that
 
@Neil you disappoint me young padawan
 
8:59 AM
I heard a talk a while back about how when COM came out, native devs were shocked at how slow COM calls were, even between two components in-memory. COM calls had a lot of overhead, needed to serialize some data types, and in general seemed like a waste of time.
 
:)
 
actually, how would an async stream of bytes look like?
AsyncEnumerable<Byte> ?
 

« first day (3342 days earlier)      last day (1589 days later) »