Hi,
I have created a custom Appointment class which implements Telerik.WinControls.UI.Appointment.
I store a few fields in this class and they are stored in a database via a custom Edit Appointment Dialog.
I have enabled the recurrence dialog recently and this works fine - can add a recurrence rule and this generates occurrences, etc. Looking at the other threads, I figured I had to include the following in my custom class for this to happen:
 
 
 
 
 
 
The issue I now face is that I want to store the RecurrenceRule in my database (right now recurrence only works in-memory). To do this, I have a string field "JobRecurrenceRule" which is stored in the database.
When an appointment is to be saved to the database, I do the following:
When appointments are read from the database, I do the following to instantiate RecurrenceRule:
The recurrence rule is being correctly saved to the database, but when I try to load the appointment back from the database, the scheduler seems to freeze. I get a context switch deadlock:
ContextSwitchDeadlock was detected
Message: The CLR has been unable to transition from COM context 0x4ac6f90 to COM context 0x4ac7100 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.
I have traced the freezing down to the code where I add the appointment with the RecurrenceRule to the RadScheduler.
Commenting out the line:
Therefore, not reading the recurrence rule from the database, prevents this deadlock.
I am assuming that something is not quite right with the way I am loading the RecurrenceRule from the database. Perhaps I am missing something? Any help much appreciated.
Regards.
                                I have created a custom Appointment class which implements Telerik.WinControls.UI.Appointment.
I store a few fields in this class and they are stored in a database via a custom Edit Appointment Dialog.
I have enabled the recurrence dialog recently and this works fine - can add a recurrence rule and this generates occurrences, etc. Looking at the other threads, I figured I had to include the following in my custom class for this to happen:
Private _masterEvent As Telerik.WinControls.UI.IEvent   Public Shadows ReadOnly Property MasterEvent() As Telerik.WinControls.UI.IEvent        Get            If Object.Equals(_masterEvent, Nothing) Then                Return Nothing            Else                Return _masterEvent            End If        End Get    End Property    Public Overrides Function CreateOccurrence(start As Date) As Telerik.WinControls.UI.IEvent        Dim appointment As New JobAppointment()        Dim startDate As Date = start        Dim ts As TimeSpan = Me.Duration        Dim endDate As Date = startDate.Add(ts)        ..........        'Added this to set the settings required by Telerik.        appointment.ApplySettingsToAppointment()        'For repeated occurrences..        Dim appType As Type = GetType(Telerik.WinControls.UI.Appointment)        appType.GetField("masterEvent", System.Reflection.BindingFlags.Instance Or System.Reflection.BindingFlags.NonPublic).SetValue(appointment, Me)        Return appointment    End FunctionThe issue I now face is that I want to store the RecurrenceRule in my database (right now recurrence only works in-memory). To do this, I have a string field "JobRecurrenceRule" which is stored in the database.
When an appointment is to be saved to the database, I do the following:
If RecurrenceRule IsNot Nothing Then If RecurrenceRule.IsValid Then JobRecurrenceRule = CalHelper.RecurrenceRuleToString(RecurrenceRule) End IfEnd IfWhen appointments are read from the database, I do the following to instantiate RecurrenceRule:
If JobRecurrenceRule <> "" Then            CalHelper.TryParseRecurrenceRule(JobRecurrenceRule, RecurrenceRule)End IfThe recurrence rule is being correctly saved to the database, but when I try to load the appointment back from the database, the scheduler seems to freeze. I get a context switch deadlock:
ContextSwitchDeadlock was detected
Message: The CLR has been unable to transition from COM context 0x4ac6f90 to COM context 0x4ac7100 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.
I have traced the freezing down to the code where I add the appointment with the RecurrenceRule to the RadScheduler.
Commenting out the line:
CalHelper.TryParseRecurrenceRule(JobRecurrenceRule, RecurrenceRule)Therefore, not reading the recurrence rule from the database, prevents this deadlock.
I am assuming that something is not quite right with the way I am loading the RecurrenceRule from the database. Perhaps I am missing something? Any help much appreciated.
Regards.
