dcsimg
Results 1 to 4 of 4

Thread: [RESOLVED] Prevent user actions queuing-up while application is busy in WPF

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2016
    Posts
    97

    Resolved [RESOLVED] Prevent user actions queuing-up while application is busy in WPF

    I have converted following vb.net codes from this link: https://stackoverflow.com/questions/...cation-is-busy

    ViewModel:

    Code:
      
    Class MainWindow
    
        Private _appIdle As Boolean = True
    
        Private Sub Hooks_OperationStarted(ByVal sender As Object, ByVal e As Windows.Threading.DispatcherHookEventArgs)
            ApplicationIdle = False
        End Sub
    
        Private Sub Hooks_OperationCompleted(ByVal sender As Object, ByVal e As Windows.Threading.DispatcherHookEventArgs)
            ApplicationIdle = True
        End Sub
    
        Public Property ApplicationIdle As Boolean
            Get
                Return _appIdle
            End Get
            Set(ByVal value As Boolean)
                _appIdle = value
                RaisePropertyChanged("ApplicationIdle")
            End Set
        End Property
    
        Public Sub MainWindowViewModel()
            Application.Current.Dispatcher.Hooks.OperationStarted += AddressOf Hooks_OperationStarted
            Application.Current.Dispatcher.Hooks.OperationCompleted += AddressOf Hooks_OperationCompleted
        End Sub
    
    End Class
    MainWindow xaml:

    Code:
    IsHitTestVisible="{Binding ApplicationIdle}"

    But I come across some errors as you can see in this picture: https://prnt.sc/nbn55h

    Please tell me how can I solve that errros?

    Note: I am using .NET 4.5

    Supporting link:
    https://jeremybytes.blogspot.com/201...tychanged.html
    Last edited by Kram Kramer; Apr 14th, 2019 at 08:54 AM.

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Dec 2016
    Posts
    97

    Re: Prevent user actions queuing-up while application is busy in WPF

    Any solution here?

  3. #3
    Fanatic Member PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Newport, UK
    Posts
    1,023

    Re: Prevent user actions queuing-up while application is busy in WPF

    VB uses the AddHandler command instead of C#'s += syntax to connect event handlers.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Dec 2016
    Posts
    97

    Re: Prevent user actions queuing-up while application is busy in WPF

    Following codes solve my problem thanks to PlausiblyDamp.

    Code:
    AddHandler Application.Current.Dispatcher.Hooks.OperationStarted, AddressOf Hooks_OperationStarted
    AddHandler Application.Current.Dispatcher.Hooks.OperationCompleted, AddressOf Hooks_OperationCompleted
    Now how to solve last error:
    'RaisePropertyChanged' is not declared. It may be inaccessible due to its protection level.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width