We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Unhandled exception when modyfing binded CalendarEventCollection

Hi,

We are struggled with some problem with your SfCalendar. Everythings works good until we modify the Syncfusion.SfCalendar.XForms.CalendarEventCollection which is binded with view by oneway mode.


Application let's adding a new event which should be added to the collection at runtime. It works for a while, but unfortunately after few seconds it crashes with Unhandled exception.

Here's viewmodel property binded to View:

public Syncfusion.SfCalendar.XForms.CalendarEventCollection calendarItems
{
get; private set;
}

And here's the method modyfing the collection:

public void LoadCalendarView(DateTime? switchDate = null)
{
if (calendarItems == null)
calendarItems = new Syncfusion.SfCalendar.XForms.CalendarEventCollection();

calendarItems.Clear();

var _allCalendarEvents = new Syncfusion.SfCalendar.XForms.CalendarEventCollection();

using (var db = new DbContext())
{
var result = db.GetAllUserEvents();

if (result.Status == 0)
{
foreach (var item in result.Result)
{
_allCalendarEvents.Add(new Syncfusion.SfCalendar.XForms.CalendarInlineEvent
{
Color = item.EventColor,
EndTime = item.EventEndDate,
StartTime = item.EventStartDate,
Subject = item.EventDescription
});
}

foreach(var item in _allCalendarEvents)
{
calendarItems.Add(item);
}
}
}
if (switchDate.HasValue)
selectedDate = switchDate.Value;
else
selectedDate = DateTime.Now;

}

Here's a xaml fragment

DataSource="{Binding calendarItems, Mode=OneWay}" TransitionMode="Float" ShowHeader="True" SelectedDate="{Binding selectedDate, Mode=TwoWay}" ShowNavigationButtons="True" ViewMode="MonthView" ShowInlineEvents="False" HeightRequest="400" FirstDayofWeek="1">




We suspect that the exception might be thrown by an background task because GUI is responsive by the time it gets crashed.



6 Replies

RG Rajkumar Ganesamoorthy Syncfusion Team November 29, 2016 11:41 AM UTC

Hi Piotr,

Thank you for contacting Syncfusion Support.

Issue: Unhandled exception when modyfing binded CalendarEventCollection

We have checked your reported issue in our side but we were unable to reproduce the reported issue in our side. So could you please provide stack trace details of the SfCalendar that will help us to provide appropriate solution on this.

Regards,
Rajkumar G



































PI Piotr December 5, 2016 01:26 PM UTC

Hi Rajkumar,

Thank you for your reply. Could you please provide me your Test Case project so I could modify it to reproduce this issue and show the particular exception?

Thank you in advance, 
Regards
Piotr



RG Rajkumar Ganesamoorthy Syncfusion Team December 6, 2016 12:02 PM UTC

Hi Piotr,

Thanks for your update.

We have attached a sample in which we have checked your reported issue in our side. Please find the sample from below

Sample: http://www.syncfusion.com/downloads/support/forum/127615/ze/issueTesting-1081546263
 

So could you please modify the above sample to reproduce the reported issue .

Regards,
Rajkumar G





 



PI Piotr December 7, 2016 04:36 PM UTC

Hi Rajkumar, 

Thank you kindly for your reply, 
I have updated your solution to match the issue. The problem occurs when you want to modify collection from another thread. This is normally possible in other controls like ListView. 
 

Attachment: issueTestingMatch_712afdde.zip


PI Piotr December 7, 2016 05:24 PM UTC

I have also encountered this sort of exception when the calendar was working on the main thread: 

at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/3859/b638977c/source/xamarin-macios/src/UIKit/UIApplication.cs:79 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/3859/b638977c/source/xamarin-macios/src/UIKit/UIApplication.cs:63 
  at IQOSMobile.iOS.Application.Main (System.String[] args) [0x00001] in Main.cs


RG Rajkumar Ganesamoorthy Syncfusion Team December 14, 2016 11:43 AM UTC

Hi Piotr,

Thanks for your update.

We have analyzed the reported issue "Unhandle exception" in our side based on your provided sample, from that we have found the following

1)When we try to pop the application page in background process the reported issue get occured.

2)if we pop the event(button click event in our sample) of any UI in background process , the reported issue occured. Please find the Xamarin forums link related to this reported issue

Link:  https://forums.xamarin.com/discussion/50338/consistency-error-you-are-calling-a-uikit-method-that-can-only-be-invoked-from-the-ui-thread

We can add the long time process in application background process by using Device.BeginInvokeOnMainThread. We have preapred sample to show demo on how to handle the long time process in application background process. Please find the sample from below

Sample:  http://www.syncfusion.com/downloads/support/forum/127615/ze/issueTesting_3698012279 
Regards,
Rajkumar G 


Loader.
Live Chat Icon For mobile
Up arrow icon