public void UpdateTask()
		{
			SyncSem.WaitOne();

			if (syncEngine.SyncCanceled)
			{
				UpdateSem.Release();
				return;
			}

			syncEngine.CurrentTotal += MapAdded.Count + MapUpdated.Count;

			rdoSession = new RDOSessionClass();
			rdoSession.MAPIOBJECT = nsObject;
			rdoAddressBook = rdoSession.AddressBook;
			rdoAddressList = rdoAddressBook.GAL;
			rdoFld = rdoSession.GetDefaultFolder(rdoDefaultFolders.olFolderContacts);
			rdoItems = rdoFld.Items;

			foreach (Contact c in MapUpdated.Values)
			{
				if (owner != null)
				{
					Dispatcher.Invoke(new SyncProgressEventHandler(owner.Progress), this,
						"Updating " + "(" + syncEngine.CurrentItemNum + "/" + syncEngine.CurrentTotal + ")",
						syncEngine.CurrentItemNum, syncEngine.CurrentTotal);
					syncEngine.CurrentItemNum++;
				}

				RDOContactItem ctc = rdoItems[indexByFullname[c.FullName]] as RDOContactItem;
				FillProviderCreatedItem(c, ctc);
				ctc.Save();
			}

			foreach (Contact contact in MapAdded.Values)
			{
				if (owner != null)
				{
					Dispatcher.Invoke(new SyncProgressEventHandler(owner.Progress), this,
						"Updating " + "(" + syncEngine.CurrentItemNum + "/" + syncEngine.CurrentTotal + ")",
						syncEngine.CurrentItemNum, syncEngine.CurrentTotal);
					syncEngine.CurrentItemNum++;
				}

				if (contact.FullName != "")
				{
					RDOContactItem ctc = rdoItems.Add("IPM.Contact") as RDOContactItem;

					if (ctc != null)
						FillProviderCreatedItem(contact, ctc);

					ctc.Save();
				}
				else
				{
				}

				
			}

			UpdateSem.Release();
		}
		public OutlookContactsProvider(IGUICallbacks host, SyncEngine syncEngine)
		{
			owner = host;

			outlookApp = new Microsoft.Office.Interop.Outlook.ApplicationClass();
			Microsoft.Office.Interop.Outlook.NameSpace ns = outlookApp .GetNamespace("MAPI");
			nsObject = ns.MAPIOBJECT;

			if (!IsRedemptionInstalled())
			{
				Process reg = new Process();
				reg.StartInfo.FileName = "regsvr32.exe";
				reg.StartInfo.Arguments = "/s Redemption.dll";
				reg.StartInfo.UseShellExecute = false;
				reg.StartInfo.CreateNoWindow = true;
				reg.StartInfo.RedirectStandardOutput = true;
				reg.Start();
				reg.WaitForExit();
				reg.Close();
			}
			else
			{
			}

			rdoSession = new RDOSessionClass();
			try
			{
				rdoSession.MAPIOBJECT = nsObject;
			}
			catch
			{
				Microsoft.Office.Interop.Outlook.MAPIFolder mf = outlookApp.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts);
				string pstPath = GetStorePath(mf.StoreID);
				//string pstPath = @"C:\Users\maxim\AppData\Local\Microsoft\Outlook\Outlook.pst";
				rdoSession.LogonPstStore(pstPath, 1, "", "", 0);
			}
			
			rdoAddressBook = rdoSession.AddressBook;
			rdoAddressList = rdoAddressBook.GAL;
			rdoFld = rdoSession.GetDefaultFolder(rdoDefaultFolders.olFolderContacts);
			rdoItems = rdoFld.Items;

			this.syncEngine = syncEngine;
		}