Ticket T242056
Visible to All Users

XAF - How to auto refresh View data periodically using a timer or from a background thread

created 10 years ago

I saw about a year ago there was a way to refresh the data for xaf when using a WEB application, is there an example of how this might be done on the windows side?

Thanks Joe.

Answers approved by DevExpress Support

created 10 years ago (modified a month ago)

Hello Joe,

ASP.NET Core Blazor

To implement custom logic in background (for example, update a View periodically on timer events), you can use the new BlazorApplication.InvokeAsync method in v24.2+. For more information, review the docs with code examples at InvokeAsync | Refresh Data in a View After a Period of Time (ASP.NET Core Blazor). I hope this helps.

WinForms

The closest WinForms example I found is Refresh DetailView of NonPersistent object using Timer. However, it is not quite clear whether it will meet your needs.
Would you please elaborate a bit more on the use-case scenario you need to handle as well as on the ultimate goal from an end-user perspective clarifying why this refresh is necessary?

You can consider the following general implementation plan to handle such tasks:
1. Triggering actions periodically.
This part is not specific to XAF, and you can use various standard .NET Framework solutions for this.  For instance, you could use a Timer class. Refer to MSDN for more details.

2.  Calling XAF API that refreshes data.
These are ListView.CollectionSource.Reload or View.ObjectSpace.Refresh methods, where ListView/View are references to the View objects you want to be refreshed.
3. Integrating these APIs together.
For this, you can implement the ViewController or WindowController, e.g. set up a timer when View controls or the System.Windows.Forms.Form handle was created.

You can find more scenarios and possible solutions for them if you use our search engine: https://search.devexpress.com/?q=WinForms%20refresh%20timer%20.net%20frameworks%20(xaf%20&%20xpo)%20eaf%20expressapp%20framework%20xaf&m=SupportCenter

ASP.NET WebForms

Refresh Data in a View After a Period of Time (ASP.NET Web Forms)

    Comments (2)

      Disregard the first post as I misunderstood my own problem. Feel free to delete this supportticket and make a new one with the below explanation:
      We've built a support system where our customer service registers and processes SupportIssues(XPO class). When the front desk gets a call from a customer he/she registers a SupportIssue and assigns it to one of our many support groups, for instance tech support, billing etc. So if a the front desk registers a SupportIssue and assigns it to tech support they need to be notified about the new issue.
      The way it is done now is that when a SupportIssue is saved at the front desk, a file is written to a shared file location which is watched by the application. If the application sees a new file it will fire of an event which is registered in the SupportIssueListViewController and MySupportIssuesListViewController. When this event fires we refresh the grid with:
      ((Control)Frame.Template).Invoke(new ThreadStart(() => ((DevExpress.ExpressApp.ListView)View).CollectionSource.Refresh()));
      Tech support will now see the new issue and can start processing it. The problem is that the refresh on the collectionsource takes a couple of seconds(and potentially runs two times if both the SupportIssueListViewController and MySupportIssuesListViewController is active) so if the user on tech support is already inputting data in the DetailView on another SupportIssue the application will freeze while the refresh is happening, which annoys them.
      Ideally the refresh would happen when the ListView is focused again. I've also considered just adding a notification icon to the toolbar and turn that on instead of automatically refreshing the ListView, so that the user must manually refresh the listview when he sees the notification icon.
      Any suggestions would be greatly appreciated.
      Regards
      Terje

      Dennis Garavsky (DevExpress) 10 years ago

        Hello Terje,

        To process your recent post more efficiently, I created a separate ticket on your behalf: T248114: Refreshing ListView questions. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.