Event loop when saving Task item in event handler

Event loop when saving Task item in event handler

Post by Mustaf » Sat, 09 Aug 2008 19:46:28

Hi all,

Please go through my problem and see if you can help me out..

The scenario is like this, suppose you have a text box and you
registered an event Handler on TextChanged Event like

this.textBox1.TextChanged += new

But if I change the Text value of this TextBox inside this TextChanged
event hanlder itself, It will create a loop, because as soon as I
change the text value, TextChange Event will fire, which will invoke
the event Handler, So to avoide this loop, inside the event handler
first i will remove the event handler on the TextChanged Event, modify
the text value and again register the event handler as shown in the
below code...

private void textBox1_TextChanged(object sender, EventArgs e)
this.textBox1.TextChanged -= this.textBox1_TextChanged; //
Remove Handler
this.textBox1.Text = System.DateTime.Now.ToString(); //
Update Data
this.textBox1.TextChanged += this.textBox1_TextChanged; //
Add Handler

this is working fine for UI objects like TextBox. But I want simulate
this functionality for Outlook Tasks Items some thing like shown

using OL = Microsoft.office.Interopservices.Outlook;

class TestOutlook
OL.Application App = null;
OL.NameSpace Ns = null;
OL.MAPIFolder Tasks = null;

private void InitializeOutllok()
App = new OL.Application();
Ns = App.GetNamespace("MAPI");
Tasks =
Ns .GetDefaultFolder(OL.OlDefaultFolders.olFolderTasks);

Tasks.Items.ItemChange += Items_ItemChange; // Register Event

private void Items_ItemChange(Object pItem)
OL.TaskItem UpdatedTask = null;

Tasks.Items.ItemChange -= Items_ItemChange; // Remove
OL.TaskItem UpdatedTask = (OL.TaskItem) pItem; // Update it
UpdatedTask.DueDate = System.DateTime.Now;
Tasks.Items.ItemChange += Items_ItemChange; // Add Handler
catch(Exception Ex)





But I am unable to simulate this for Outlook Tasks Items(Folder)

Mohamed Mustafa

Event loop when saving Task item in event handler

Post by Dmitry Str » Sun, 10 Aug 2008 02:24:53

See my reply in com.add-ins.
Please do not multipost.

Dmitry Streblechenko (MVP)
OutlookSpy - Outlook, CDO
and MAPI Developer Tool