This is a migrated thread and some comments may be shown as answers.

RadScheduler datasource, update is slow.

1 Answer 140 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
Jill-Connie Lorentsen
Top achievements
Rank 1
Jill-Connie Lorentsen asked on 23 Jun 2014, 11:57 AM
I have a RadScheduler with a datasource initated like this:

private void InitiateBookingDataSource()
        {
            if (_appointmentBookings == null) _appointmentBookings = new BindingList<Booking>();
 
            var dataSource = new SchedulerBindingDataSource();
            var mappingInfo = new AppointmentMappingInfo
                                  {
                                      Start = "StartTime",
                                      End = "EndTime",
                                      Summary = "BookingSubject",
                                      Description = "BookingDescription",
                                      BackgroundId = "BackgroundId",
                                      AllDay = "AllDay",
                                      RecurrenceRule = "RecurrenceRule",
                                      Exceptions = "Exceptions",
                                      MasterEventId = "MasterEventId",
                                      Visible = "Visible"
                                  };
 
            mappingInfo.Mappings.Add(new SchedulerMapping("CaseId", "CaseId"));
            mappingInfo.Mappings.Add(new SchedulerMapping("PratId", "PratId"));
            mappingInfo.Mappings.Add(new SchedulerMapping("BoothId", "BoothId"));
            mappingInfo.Mappings.Add(new SchedulerMapping("CaseDesc", "CaseDesc"));
            mappingInfo.Mappings.Add(new SchedulerMapping("BoothDesc", "BoothDesc"));
 
            dataSource.EventProvider.Mapping = mappingInfo;
            dataSource.EventProvider.DataSource = _appointmentBookings;
            dataSource.EventProvider.AppointmentFactory = rsBookings.AppointmentFactory;
 
            rsBookings.DataSource = dataSource;
        }

The appointments are initiated and updated by calling the method below. The problem is that it takes "forever" if the number of appointments exceeds approx 50. Is there a way to speed it up? I have tried async await, but as I am new to that procedure I haven't been able to implement it successfully.

Regards, Jill-Connie Lorentsen
private void InitiateAppointments(IEnumerable<Booking> bookings)
       {
           try
           {
               if (_appointmentBookings == null) _appointmentBookings = new BindingList<Booking>();
                
               rsBookings.Appointments.Clear();
               _appointmentBookings.Clear();
                
               foreach (var booking in bookings)
               {
                   var appointment = booking;
                   appointment.BackgroundId = _booths.Find(b => b.BoothId == booking.BoothId).BackgroundId;
                   appointment.Exceptions.ForEach(b => b.BackgroundId = _booths.Find(x => x.BoothId == b.BoothId).BackgroundId);
                   _appointmentBookings.Add(appointment);
               }
             
           }
           catch (Exception ex)
           {
              MessageBox.Show(ex.Message);
           }            
       }

1 Answer, 1 is accepted

Sort by
0
George
Telerik team
answered on 26 Jun 2014, 08:53 AM
Hi Jill,

Thank you for contacting us.

Since the problem occurs in the InitiateAppointments method my guess is that the collections you are iterating are quite large. I see that you are iterating the bookings collection, then for each booking you iterate the _booths and then for each exception in each appointment also iterate the _booths collection. All of these operations are with linear complexity which can be slow with large collections. I would recommend you to try to optimize that method. You can also provide me with more details about your case and the collections at hand. Possibly with a sample project which I can investigate locally.

Looking forward to your response.

Regards,
George
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
Scheduler and Reminder
Asked by
Jill-Connie Lorentsen
Top achievements
Rank 1
Answers by
George
Telerik team
Share this question
or