« first day (2495 days earlier)      last day (1654 days later) » 

2:31 AM
0
Q: Set the max height of wpf window based on available screen's size

MegaMindI have a WPF window which runs on multiple monitors having different resolutions. It'll be good but not required to be smart enough to change max height when I move the window from high-resolution monitor to low-resolution monitor or vice-versa. Current requirement is simple enough to set the ma...

 
 
5 hours later…
8:00 AM
Good morning
 
 
2 hours later…
9:58 AM
Morning
 
Good morning
 
Hi Maverik
 
 
3 hours later…
12:42 PM
Been reading about a getter calling an async method using the 2nd example from our own Reed: stackoverflow.com/a/6602402/177416
Is this calling the method async?
// Make the property blocking
public IEnumerable MyList
{
    get
    {
         // Block via .Result
         return MyAsyncMethod().Result;
    }
}
I think not b/c it's blocking
Then there's this way....
Dispatcher.CurrentDispatcher.InvokeAsync(async () => { MyList = await MyAsyncMethod(); });
But this ^ "eats" any exceptions in the called method
 
1:09 PM
From what I've heard calling Result doesn't guarantee to return results on completion. And I always used await Task.Run(); with async method
And good morning :-)
 
 
2 hours later…
2:58 PM
@XAMlMAX Thanks, Xaml
This should do the trick:
Task.Run(async () => { MyList = await MyAsyncMethod(); });
Is this ^ safe, as in, if that task takes a while to finish, is it okay to use it in a c'tor?
It should finish in a second but what if MyAsyncMethod() blows up?
 
3:18 PM
New approach: We'll call the async method on the object. Never a good idea to do async in c'tor or props
@Julien Cool. Didn't know that was possible w/ switch
 
I used it as a async InitialiseComponents(); like
private async void Init() { Task.Run(() => doSomethingHere()); } then you can just call that in your constructor like Init();
 
Standard disclaimer about async void...
Make sure you catch your exceptions
 
3:34 PM
Void eats the exceptions
Is it okay to call async directly/indirectly from a c'tor?
 
No, it doesn't
void will rethrow to the root handler if not caught
 
Oh
Remember reading on async void and how it was bad
 
and yes, you can call them, its just not ideal since async void becomes necessary
Many times there are no better option though
 
How about using this in the c'tor: Task.Run(async () => { MyList = await MyAsyncMethod(); });
 
same issue AFAIK
 
3:44 PM
Makes sense
 
but if you can summon Reed he would know more
 
Thanks, Bradley
Yeah, he had provided the answer on the linked question above
 
 
1 hour later…
5:07 PM
posted on August 19, 2019 by Glenn Condron [MSFT]

In preview7 a new package was added to the Microsoft.Extensions set of packages that enables integration with systemd. For the Windows focused, systemd allows similar functionality to Windows Services, there is a post on how to do what we discuss here for Windows Services in this post. The post .NET Core and systemd appeared first on .NET Blog.

 

« first day (2495 days earlier)      last day (1654 days later) »