Hello, how is it possible to refresh data in timer event in a ViewController without getting the "Cross-thread operation not valid" message
This is my timer event in the viewcontroller
void EvRefreshTimer_Elapsed(object sender, ElapsedEventArgs e)
{
View.ObjectSpace.Refresh();
//Frame.GetController<DevExpress.ExpressApp.SystemModule.RefreshController>().RefreshAction.DoExecute();
}
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.
Hello Trond,
It appears that the following Support Center issues will be helpful: Q106745 (Live view of listview modified by external windows service), Q131168 (How to developer one listview equal Live Data of ASPxGridView).
Is the problem resolved? If not, please describe your real scenario, i.e. why you need to refresh the View's content on a timer event, and provide a sample project, reproducing your situation, so we can improve it.
Thanks,
Anatol
No, this did not solve my problem. I have attached a sample project. I'm using a timer here for testing purpose and simplicity, but i real life I'm using a FileSystemWatcher to trigger the refresh.
The MasterObject contains a readonly collections of subobjects I want go refresh when other users change a subobject's state to Open.
Just run the application and register a new master objects. When the timer triggers you get the error message.
Thanks.
Trond
Hello Trond,
Thank you for your sample. Unfortunately, today we've been a little bit overloaded with support queries.
We are working on your issue, and will answer you ASAP.
Thanks,
Anatol
Hello Trond,
I apologize for the delay in responding. To solve the problem, you should update the GridControl's datasource in the same thread, in which the GridControl is created. To do it, use the Control.Invoke method, as shown in the following code:
void fRefreshTimer_Elapsed(object sender, ElapsedEventArgs e) { ((Control)Frame.Template).Invoke(new ThreadStart(delegate() { ((DevExpress.ExpressApp.ListView)View).CollectionSource.Reload(); })); }
Please let me know if you need any further help.
Thanks,
Anatol
Perfect !
Thanks.