Hi,
during the processing of incoming Push Notification Events (the Event Handler is a thread safe delegate) I have to create a new ExchangeService object and set its ImpersonateId multiple times during the event to replicate the changes of this event back to other Exchange mailboxes. Are the ExchangeService objects expensive? The garbage collector should destroy those objects used in past events, shouldnt it? Code for the delegate would be sth like this:
if (bocet.Item is ItemIdType)
{
ExchangeService tempService = new ExchangeService(exchVersion);
tempService.Credentials = credentials;
tempService.Url = new Uri(EWS_URL);
tempService.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, dicUsersSubscriptionIDs[subscriptionId]);
ItemIdType itemId = bocet.Item as ItemIdType;
DataTable dt=GetAffectedUsersSMTP();
foreach (DataRow rw in DataTable dt)
{
tempService.ImpersonatedUserId.Id=rw["SMTPAddress"].toString();
//Bind affected contact item of other users
//update contact item with tempservice
//move on to the next datarow
}
}
Thank you for your thoughts.