Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Geert van Horrik
    @GeertvanHorrik
    CloseApplicationWatcherBase
    just implement a watcher deriving from that one
    and register it in the servicelocator with RegisterAndInstantiate<MyWatcher>()
    you should ask your company to sponsor us ;-)
    advapiIT
    @advapiIT
    yup I'll do
    Geert van Horrik
    @GeertvanHorrik
    on open collective you'll even get an invoice
    advapiIT
    @advapiIT
    let me finish it and I'll contribute
    I promise
    Geert van Horrik
    @GeertvanHorrik
    that's the point, it should not be you, it should be your company / manager / whatever
    anyway, this watcher is very nice
    you can handle it there
    so in our internal libs, we have created a watcher that intercepts that closing, and exposes that via a service, so we can prevent closing from basically everywhere
    advapiIT
    @advapiIT
    TypeNotRegisteredException: The specified type 'Orchestra.CloseApplicationWatcherBase, Orchestra.Core, Version=5.2.6.0, Culture=neutral, PublicKeyToken=null' is not registered or could not be constructed. Please register type before using it. The type 'Orchestra.CloseApplicationWatcherBase, Orchestra.Core, Version=5.2.6.0, Culture=neutral, PublicKeyToken=null' is not registered
    Geert van Horrik
    @GeertvanHorrik
    public abstract class CloseApplicationWatcherBase
    but.....
    advapiIT
    @advapiIT
    Ah I've to derive from it
    Geert van Horrik
    @GeertvanHorrik
        public class ApplicationClosingService : CloseApplicationWatcherBase, IApplicationClosingService
        {
            public bool IsClosing { get; private set; }
    
            public event AsyncEventHandler<EventArgs> ApplicationClosingAsync;
            public event EventHandler<EventArgs> ApplicationClosingCanceled;
    
            protected override async Task<bool> ClosingAsync()
            {
                IsClosing = true;
    
                await ApplicationClosingAsync.SafeInvokeAsync(this, EventArgs.Empty);
    
                return await base.ClosingAsync();
            }
    
            protected override void ClosingCanceled()
            {
                IsClosing = false;
    
                ApplicationClosingCanceled?.Invoke(this, EventArgs.Empty);
    
                base.ClosingCanceled();
            }
        }
    this is our internal implementation, then you can simply subscribe to IApplicationClosingService::ApplicationClosing and cancel it from there
    advapiIT
    @advapiIT
    excuse me again, but when I subscribe to ApplicationClosing, how can I cancel? the EventArgs
    has no cancel prop
    Geert van Horrik
    @GeertvanHorrik
    hmmm, good question
    you can fix your own, if the eventargs of ApplicationClosingAsync has an e.Cancel
    you could cancel
    since it has a reutnr value
    advapiIT
    @advapiIT
    you're right
    advapiIT
    @advapiIT

    ok, this seems to work
    in mainviewmodel
    ```private async Task ApplicationClosingService_ApplicationClosingAsync(object sender, CancelEventArgs e)
    {
    var response = await messageService.ShowAsync("Sei sicuro di voler chiudere l'applicazione?",
    "Chiusura applicazione", MessageButton.YesNo, MessageImage.Question);
    if (response == MessageResult.No)
    {
    e.Cancel = true;
    }
    }

    in the closeService

    protected override async Task<bool> ClosingAsync()
    {
    IsClosing = true;

            var eventArgs = new CancelEventArgs();
            await ApplicationClosingAsync.SafeInvokeAsync(this, eventArgs);
    
            if (!eventArgs.Cancel)
                return await base.ClosingAsync();
            return false;
        }

    ```

    I want my mom.
    never been able to past code.
      protected override async Task<bool> ClosingAsync()
            {
                IsClosing = true;
    
                var eventArgs = new CancelEventArgs();
                await ApplicationClosingAsync.SafeInvokeAsync(this, eventArgs);
    
                if (!eventArgs.Cancel)
                    return await base.ClosingAsync();
                return false;
            }
    venom_aa
    @venomAA

    I want my mom.

    XD

    i want a beer and a good bbq ..working for this client has been exhausting
    advapiIT
    @advapiIT
    idem for me
    it's 2 AM here
    venom_aa
    @venomAA
    tssss.. thats bad
    but i feel you
    i have working on weekends for about 3 months
    @advapiIT did the code i posted helped you>
    ?
    advapiIT
    @advapiIT
    yup thansk
    venom_aa
    @venomAA
    np mate
    and grab a beer ...that always helps to code faster when you are working that late XD
    pretty sure geert made catel with more than a few beers on xD
    advapiIT
    @advapiIT
    with some pot!
    venom_aa
    @venomAA
    xD
    as a distraction..search the google maps for dispensaries around silicon valley... XD
    advapiIT
    @advapiIT
    lol
    u work here?
    no u're from brazil if I remembrer correctly
    venom_aa
    @venomAA
    on sillicon valley? haha i wish
    no..from mexico