Re: Pocket outlook - AppointmentsCollection class: ListChanged event

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



It would be a good idea to know something about how a Windows program works
before you set off to write one. Read a chapter or two from the old Petzold
book, for example, Programming Windows. Chris is telling you that you can't
do what you want without a message pump, which is automatically there when
you build a forms-based application, but which does not exist in a console
application. So, you either need to build your application as forms-based
or you need to build your own message pump. If you want to do the latter
and stay as a console application, you must have a minimal understanding of
what a message pump is...

Paul T.

"Sam" <NOSPAM@xxxxxxxxxx> wrote in message
news:84766C95-12F9-4FC7-BD04-003476E6A3E2@xxxxxxxxxxxxxxxx
I don't know much about what are you talking about...please can you give me
any link?
Thanks..
"Chris Tacke, eMVP" <ctacke.at.opennetcf.dot.com> wrote in message
news:%23MCwTjmsJHA.2376@xxxxxxxxxxxxxxxxxxxxxxx
IIRC, it works via Windows Messages, so you have to have a message pump to
get the notifications. Sleep won't do it - you need to Get and Dispatch
messages from the queue.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com



"Sam" <NOSPAM@xxxxxxxxxx> wrote in message
news:30170083-044D-470C-A7C8-477E6D701079@xxxxxxxxxxxxxxxx
>
http://blog.opennetcf.com/ctacke/2008/10/20/TheCuttingRoomDetectingPOOMChanges.aspx
Thank you very much. It is very useful!!
It works with windows form but I'm not able to integrate it into my
console application.
Please, I need help! Where I should put this code?
POOMHelper.OutlookItemChanged += new
OutlookItemChangeDelegate(POOMHelper_OutlookItemChanged);

void POOMHelper_OutlookItemChanged(PIMNotificationMessage notification,
PIMItemType itemType, int itemOID, int databaseOID)

{

switch (itemType)

{

case PIMItemType.Calendar:

{...}

break;}}


My Console application:

class Program
{
static Timer timer= new Timer();
static void Main(string[] args)
{
timer = new Timer();
timer.Interval = 500;
timer.OnTimerTick += timerTick;
Thread timerThread = timer.Start();
for (; ; )
Thread.Sleep(5000);
}

And:

class Timer
{
// Delegates
public delegate void Tick();

// Properties
public int Interval;
public Tick OnTimerTick;

// Private Data
Thread _timerThread;
volatile bool _bStop;

public void SleepIntermittently(int totalTime)
{
int sleptTime = 0;
int intermittentSleepIncrement = 10;

while (!_bStop && sleptTime < totalTime)
{
Thread.Sleep(intermittentSleepIncrement);
sleptTime += intermittentSleepIncrement;
}
}

public void Run()
{
while (!_bStop)
{
// Sleep for the timer interval
SleepIntermittently(Interval);
// Then fire the tick event
OnTimerTick();
}
}

public Thread Start()
{
_bStop = false;
_timerThread = new Thread(new ThreadStart(Run));
_timerThread.IsBackground = true;
_timerThread.Start();
return _timerThread;
}

public void Stop()
{
// Request the loop to stop
_bStop = true;
_timerThread.Join(1000);
_timerThread.Abort();
}
}


.



Relevant Pages

  • Re: Pocket outlook - AppointmentsCollection class: ListChanged event
    ... The SDF has a pump that can run with no Form at all ), ... Windows Messages. ... Thread timerThread = timer.Start; ... public void SleepIntermittently ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Pocket outlook - AppointmentsCollection class: ListChanged eve
    ... Visual Developer - Device Application Development MVP ... Chris Tacke, Embedded MVP ... Windows Messages. ... could put this code in a windows app but write you're own message pump ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Problem with Timer object
    ... private int dx = DX; ... public void beginOperation() { ... The newer compilers are much faster but direct rendering using a BufferStrategy on a Panel or Window/JWindow, under Windows XP anyway, is very very fast. ...
    (comp.lang.java.help)
  • Fishy Behavior when using Managed code in Unmanaged environment
    ... We have an MFC application that is compiled under VS 2003 (its a pure ... AND THEN we found this article on MSDN "Windows Forms and Unmanaged ... When you open a Windows Form from a COM client application, ... Is this message pump incompatibility the real reason for our keyboard ...
    (microsoft.public.dotnet.framework.interop)
  • Re: FPC 2.0.2 Win32 Console Application and GetOpenFileName() Dialog
    ... I do have a Petzold Book (Programming Windows 3.1). ... the sections that explain about the message pump. ... control some of the behavior of the dialogbox while it is open. ... a parameter named message) and setfocus is a windows API function. ...
    (comp.lang.pascal.misc)