Daltz333
Daltz333
CC#
Created by Daltz333 on 6/23/2023 in #help
✅ Optimizing `HTTPClient.GetAsync()` and large strings
I am writing a client application that consumes a web API at a near real-time rate (100ms). I am using httpClient.GetAsync() to retrieve the content and then I grab the string contents with Content.ReadAsStringAsync(). Then, I deserialize it with JsonConvert.DeserializeObject<T>() to a format I expect (in some cases (out of my control), it's impossible to directly deserialize, in which case I deserialize to dynamic to parse manually). Because this is done every 100ms, it's creating a large number of GC (short, but frequent) creating some pretty bad GC pressure. This is on the count of ~10 ~5ms GCs/s. Unfortunately, this can dramatically slow down execution, especially since GCs block all threads, including GUI. I assume there are strategies to mitigate and solve this, this has to be a solved problem. Unfortunately, I'm not finding reliable/updated answers in google (the most common answer is... don't use C#).
72 replies
CC#
Created by Daltz333 on 6/22/2023 in #help
❔ WinUI3: Restoring Window Size on relaunch
In UWP and WinUI2, it would automatically relaunch to the last width/height of the application, but this behavior is different in WinUI3? Is there an easy way of duplicating the existing behavior?
3 replies
CC#
Created by Daltz333 on 5/24/2023 in #help
❔ Unable to bind CollectionView to Dictionary
When binding a CollectionView to a Dictionary, MAUI throws a XAML exception of
Error: Cannot get 'Item' value (type 'Object') from type 'Microsoft.Maui.Controls.Platform.ItemTemplateContext'. BindingExpression: Path='Item' DataItem='Microsoft.Maui.Controls.Platform.ItemTemplateContext'; target element is 'Microsoft.Maui.Controls.Platform.ItemContentControl' (Name='ItemContentControl'); target property is 'FormsDataContext' (type 'Object').
Error: Cannot get 'Item' value (type 'Object') from type 'Microsoft.Maui.Controls.Platform.ItemTemplateContext'. BindingExpression: Path='Item' DataItem='Microsoft.Maui.Controls.Platform.ItemTemplateContext'; target element is 'Microsoft.Maui.Controls.Platform.ItemContentControl' (Name='ItemContentControl'); target property is 'FormsDataContext' (type 'Object').
This previously worked in Xamarin and the code behind is the same
2 replies
CC#
Created by Daltz333 on 5/17/2023 in #help
❔ Unable to profile WinUI3 application
I'm unable to launch the performance profiler for a WinUI3 packaged application. To begin, the steps I take are. 1. Debug -> Performance Profiler 2. Set to Release 3. Only click CPU Usage (any options or any combination also fail) 4. Start The application launch but the profiler fails to launch with the following exception.
Failed to enable requested events on system provider (0x800700aa).
Failed to enable requested events on system provider (0x800700aa).
I'll happily provide any additional information (except the project, unfortunately).
4 replies
CC#
Created by Daltz333 on 5/9/2023 in #help
❔ [MAUI] Global Activity Indicator
I have a MAUI Shell application where I'd like to show a global ActivityIndicator or loading icon. Unfortunately, I don't see a way to place an ActivityIndicator on the Shell XAML or class directly, and doing a hack with a popup page is extremely unreliable. Is there a way I can add views directly to the Shell or MainPage (which is of type Shell) directly?
2 replies
CC#
Created by Daltz333 on 5/8/2023 in #help
✅ MVVM Source Generator not copying attributes
It seems that if you do
[ObservableProperty, JsonIgnore]
private ImageSource _MyBadProperty;
[ObservableProperty, JsonIgnore]
private ImageSource _MyBadProperty;
It doesn't generate the [JsonIgnore] attribute on MyBadProperty, thus causing any serialization to fail since ImageSource throws an exception on attempted serialization. Any ideas of a workaround without just not using source generators?
3 replies
CC#
Created by Daltz333 on 5/5/2023 in #help
❔ Do static two way bindings leak XAML?
To summarize, does the following leak the ContentPage here:
<ContentPage>
<Label Text="{Binding Source={x:Static mySingleTon.Instance}, Path=myproperty}"/>
</ContentPage>
<ContentPage>
<Label Text="{Binding Source={x:Static mySingleTon.Instance}, Path=myproperty}"/>
</ContentPage>
If so, would this be an appropriate replacement, or the same issue?
public partial class MyViewModel : ObservableObject {
[ObservableProperty]
public MyObject ObjectA {
get => return mySingleton.Instance.myproperty;
}
}
public partial class MyViewModel : ObservableObject {
[ObservableProperty]
public MyObject ObjectA {
get => return mySingleton.Instance.myproperty;
}
}
Replacement paradigms would be useful.
20 replies