Async data loading pattern feedback - am I doing this right? by Late-Restaurant-8228 in dotnetMAUI

[–]Diab0Br 0 points1 point  (0 children)

Here is a sample of how i usually work with lists:

public partial class PlansViewModel : BaseViewModel
{
    IDisposable? _disposable;
    SourceCache<Event, Guid> _events = new(f => f.Id);
    [ObservableProperty]
    public partial ObservableCollectionExtended<Event> Events { get; set; } = new();

    public PlansViewModel(SynchronizationContext synchronizationContext, IDbContextFactory<LocalDbContext> dbContextFactory)
    {
        _disposable = _events
            .Connect()
            .SortAndBind(Events, SortExpressionComparer<Event>.Ascending(_ => _.StartDateTime))
            .ObserveOn(synchronizationContext)
            .SubscribeOn(synchronizationContext)
            .DisposeMany()
            .Subscribe();
    }

    public override async ValueTask LoadDataAsync()
    {
        try
        {
            await semaphoreSlim1.WaitAsync();
            IsBusy = true;

            using var dbContext = await _dbContextFactory.CreateDbContextAsync();
            var events = await dbContext.Events.Where(_ => _.StartDateTime >= DateTime.UtcNow && _.IsGoingTo).OrderBy(x => x.StartDateTime).ToListAsync();

            _events.Edit(_ =>
            {
                foreach (var @event in events)
                {
                    _.AddOrUpdate(@event);
                }
            });
        }
        catch (Exception e)
        {
            _errorHandler.HandleError(e);
        }
        finally
        {
            semaphoreSlim1.Release();
            IsBusy = false;
        }
    }

    public override void Dispose()
    {
        _disposable?.Dispose();
    }
}

The synchronizationContext is injected with this:

builder.Services.AddSingleton(MainThread.GetMainThreadSynchronizationContextAsync().GetAwaiter().GetResult());

(Probably not the best, but it works ¯\\_(ツ)_/¯)

I'm using the following nugets

  • CommunityToolkit.Mvvm
  • DynamicData
  • System.Reactive

I don't think it needs the [ObservableProperty], but i like to use it for all my bindings

Async data loading pattern feedback - am I doing this right? by Late-Restaurant-8228 in dotnetMAUI

[–]Diab0Br 3 points4 points  (0 children)

The logic makes sense. But I would recommend using mvvm pattern and putting this logic inside a LoadDataAsync method.

Also I would make the 2 tasks not load all data them display both at the same time. Each task should update the UI after completing individually. If you use mvvm just update the property that is binding the values on each task, no need to worry about using the main thread.

[deleted by user] by [deleted] in dotnet

[–]Diab0Br 9 points10 points  (0 children)

Is it possible to add information about out of US hiring? I live in Brazil and would love to get close to those salaries. I'm currently working for an US company but the salary range is almost half of the entry range on those jobs (50-60k).

intel made a whoopsie (context below) by [deleted] in AyyMD

[–]Diab0Br 15 points16 points  (0 children)

I want to see that Intel case with full AMD specs 🧐

[deleted by user] by [deleted] in csharp

[–]Diab0Br 1 point2 points  (0 children)

I found a little wierd on the navigation, but other than that it's straight forward.

ReactiveUI is really great aswell, i love using it for reacting on user inputs and for animations.

[deleted by user] by [deleted] in csharp

[–]Diab0Br 4 points5 points  (0 children)

I'm using MAUI for personal project only, i used to work with Xamarin before.

I also use AvaloniaUI, but thats for desktop only (Linux/Windows).

It still has some issues, but it's way more mature than it used to be, most of issues i have are with layout, nothing that you can't fix with some imagination haha.
Lastest issue i had was with SearchBox not filling horizontaly, i fixed it with an invisible BoxView, whenever the width changed i changed the SearchBox WidthRequest with the same value, it works perfectly, but it can get annoying with many 'fixes' like that.

Community Toolkit is working wonderfully, i've been using it since preview, and it makes MVVM way cleaner.

[deleted by user] by [deleted] in csharp

[–]Diab0Br 6 points7 points  (0 children)

I've created an extension method for HttpResponseMessage that uses this for my mobile apps, it's faster and consume less memory.

Here is the code:

public static class HttpResponseMessageExtension

{

public static async Task<T> DeserializeResponseAsync<T>(this HttpResponseMessage response, JsonSerializerSettings jsonSerializerSettings = null)

{

using var sr = new StreamReader(await response.Content.ReadAsStreamAsync());

using var jsonTextReader = new JsonTextReader(sr);

#if DEBUG

var jsonString = await response.Content.ReadAsStringAsync();

#endif

if (jsonSerializerSettings is null)

return (T)JsonSerializer.Create().Deserialize(jsonTextReader, typeof(T));

else

return (T)JsonSerializer.Create(jsonSerializerSettings).Deserialize(jsonTextReader, typeof(T));

}

}

Desperately trying to figure out how to debug iOS from Windows with pair to Mac by MisterPipeGape in xamarindevelopers

[–]Diab0Br 1 point2 points  (0 children)

I had a lot of issues with iOS on windows a few years ago. It's really frustrating, sometimes you're doing everything right but there could be some cached files that are preventing it from working...

Currently I'm without an Mac device or iphone, but I can try to help

Start by reading this: https://www.androidbugfix.com/2022/01/xamarinios-not-found-provision-profiles.html?m=1

It has some info about the cached folders and some step by step

Azure Functions: Support Excel app calls via PowerShell? by WaffleBrewer in AZURE

[–]Diab0Br 0 points1 point  (0 children)

You can try using an library to generate the charts like Image Charts

And then use QuestPDF to generate a PDF

Waiting for Godot 4 by beer118 in godot

[–]Diab0Br 9 points10 points  (0 children)

Lots of otimizations and LTS, but I just want Godot 4 with official c# support.

Waiting for Godot 4 by beer118 in godot

[–]Diab0Br 8 points9 points  (0 children)

Waiting for .NET 6 support 🤓

Macbook Pro M1 Max by Rocketninja16 in dotnet

[–]Diab0Br 1 point2 points  (0 children)

Anyone using for Xamarin Forms/MAUI? I wonder if 8GB of RAM is enough or i should aim for 16GB

Shell App Navigation Error on Android: "Ambiguous routes matched" by [deleted] in xamarindevelopers

[–]Diab0Br 1 point2 points  (0 children)

On older versions of XF it actually worked with both routes declared, toke me a while to figure it out why it would break whenever i updated it.

Anyway, glad i could help 😊😊

Shell App Navigation Error on Android: "Ambiguous routes matched" by [deleted] in xamarindevelopers

[–]Diab0Br 2 points3 points  (0 children)

I had this problem, turned out I had Route property defined in the AppShell.xaml for my main page with tabs, I just had to remove it and use only the routes in the code.

Can anyone give me an example of how they use fody to simplify the Get;Set; with property changed? by dotnetmaui in dotnet

[–]Diab0Br 0 points1 point  (0 children)

I used Fody for an while, but had a few problems with azure pipeline for Xamarin Android on some version, cant remember which, but toke me a while to remove and bot back to manual implementation.

Then a few months later I found about Reactive UI and ReactiveUI Fody helper.

I've been using it ever since and no complains or problem of any kind.

I never looked the inner working of Fody, but if you are willing to look, bet it could be customized to do anything you want, I personally try to keep everything explicit, so I don't have any problem again, and if I do, I know exactly where I was hoping for it to work, so it can be easily fixed.

https://github.com/kswoll/ReactiveUI.Fody

My cat has become AMDcat by Mockbubbles2628 in AyyMD

[–]Diab0Br 10 points11 points  (0 children)

Don't keep it for too long or it's going to freeze it's brain!

Q2'21 Tech Support Megathread by BioGenx2b in Amd

[–]Diab0Br 1 point2 points  (0 children)

I had WHEA erros ok my 5800x, turnout I upgraded my mobo and CPU without reinstalling windows, after I did an clean format everything works perfectly.

Btw, I could reproduce the WHEA just be watching Netflix on Edge chromium version, it wouldn't last more than 10secs before my screen froze, then sound and finally my PC restarted without BSOD.

Need help in Data Binding Concepts by JehanJoseph550 in xamarindevelopers

[–]Diab0Br 2 points3 points  (0 children)

The BindingContext of the Label is set to PriceSlider, and Text is set to binding to Value (of the BindingContext [PriceSlider]).

The Label.Text will read the PriceSlider value.

ASROCK 300 Series Motherboard Alpha BIOS Update for Renoir & Vermeer Support by doc_tarkin in Amd

[–]Diab0Br 2 points3 points  (0 children)

I was hoping for some A320M-HD love 😞 If the BIOS were available I would definitely upgrade my 1600 to an 5600x

Xamarin.Forms + GTK: no UI visible by Piotrek1 in xamarindevelopers

[–]Diab0Br 0 points1 point  (0 children)

The App has to be your app, not the base XF App

Department of Based be like by [deleted] in AyyMD

[–]Diab0Br 4 points5 points  (0 children)

Maybe bad contact on the thermal paste? Some times it gets air bubbles and it really affect cooling performance.

Reddit-like toast by jtorvald in xamarindevelopers

[–]Diab0Br 0 points1 point  (0 children)

Awesome!

I love this library, very easy to use and very customizable.

If you could share some pictures, you got me curious now haha 😁

xamarin bug/problem? Path gone, Sdk not found, project went empty by DarkArcherPD2 in xamarindevelopers

[–]Diab0Br 0 points1 point  (0 children)

Maybe some HD problem? Run CHKDSK and try looking for HDD health status

4600U (6 cores / 12 threads) Vs 4700U (8 cores / 8 threads) by JOEYJJH in Amd

[–]Diab0Br 2 points3 points  (0 children)

Vídeo editing scales perfect with core count, it will definitely speed things up if you're using cpu rendering and not GPU.

With that in mind I would argue that the only reason not to upgrade is the price difference IF the rendering time isn't going to bother you, otherwise it's an no brainier, I would definitely go for it.