public bool SignInForCourse(string courseName) { foreach (Course course in courseList) { if (course.Name == courseName) { if (course.Capacity > course.NrOfParticipants) { course.NrOfParticipants++; if (course.NrOfParticipants == course.Capacity) { // We do that because we get deadlock on the current client, it should be called on all the others // Instance of the current client ISchoolEvents clientCallback = OperationContext.Current.GetCallbackChannel <ISchoolEvents>(); // We remove it to prevent dealock CourseFull -= clientCallback.OnCourseFull; // Add the new full course CourseFull(course.Name); // Add the current cliet back CourseFull += clientCallback.OnCourseFull; } return(true); } } } return(false); }
public void UnsubscribeEvent() { ISchoolEvents clientCallback = OperationContext.Current.GetCallbackChannel <ISchoolEvents>(); CourseFull -= clientCallback.OnCourseFull; }