|
Hello, iv recently started to use C#, and now iv found i want to wait for an event. Im writing an application that reacts to diffrent Windows Live Messenger events. For instance, plays a sound when a message is receieved.
Im using the IMessengerAPI by adding a com reference to it in my project. I don't really need to do anything in my applications unless there is an event to react to. So i just want it to Sleep(); while there are no events, and then when an event arrives, handle it, and then go back to sleep.
So i need to create a function, WaitForAnyOfTheMsnAPIEvents(); or something like that. That Sleeps the application while it listens for events. How do i do this?
<br />
static class Program<br />
{<br />
static MessengerAPI.Messenger MSN = new MessengerAPI.Messenger();<br />
<br />
[STAThread]<br />
static void Main()<br />
{<br />
MSN.OnIMWindowDestroyed += new MessengerAPI.DMessengerEvents_OnIMWindowDestroyedEventHandler(MSN_OnIMWindowDestroyed);<br />
<br />
while(true)<br />
{<br />
WaitForAnyOfTheMsnAPIEvents(); }<br />
}<br />
<br />
static void MSN_OnIMWindowDestroyed(object pIMWindow);<br />
}<br />
Sorry if im stupid, im very new to C#, but i think this should be possible, in C++ you could do something similiar for events, WaitForMultipleObjects() etc..
Thanks in advance.
|
|
|
|
|
Just write a windows program which does nothing, this will create a message pump that will then respond to any messages that occur. It's automatic, just like it was in C++. WaitForMultipleObjects was something different, you can do that in C#, also.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Ahh i see! Thanks, but how do i create a windows program without a window, that still has a messagepump? Could you point me in the right direction? My application dosn't need a window, it uses messagebox popups.
|
|
|
|
|
One simple way would be to create a window that is not visible and does not appear in the taskbar. I'd expect you'd want your app either in the taskbar or the system tray, tho, so users can interact with it, even if only to exit it.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi!
You can achieve this very easily by replacing your while(true) loop with a call to Application.Run() .
To shut down the application just call Application.Exit() (in the OnIMWindowDestroyed event handler, for example).
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Hai every body,
I have to display a message box from a windows service.
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
A windows service has no user interface because it can start running before a user has logged into the system and will continue to run when they log off.
|
|
|
|
|
Can you give me a solution to do this.
Can i create a form in the service and show that form with that message by calling it.
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
If you can get a handle to the desktop window, then you can make that the parent of your message box. I think you need p/invoke for this, but you may not.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
You have 2 options:
1. enable "Interact with desktop" ... this is not such a good solution, direct interaction with the desktop can be a security risk.
2. use remoting to interact with a front end app running in the task tray. THis is a right bastard to get working :p but is the "correct" way
|
|
|
|
|
how to give white spaces
my string is link this...
<compile include="AssemblyInfo.cs"><subtype>Code
and i want to show like that
<compile include="AssemblyInfo.cs">
<subtype>Code
|
|
|
|
|
Situ14 wrote: how to give white spaces
my string is link this...
Code
and i want to show like that
Code
I would say there is more than enough white space already.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Environment.NewLine gives a carriage return. But, we have no idea how you render this, or where, so we can't really help much more than that
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I believe that you should have something like this:
String s="how to give white spaces"+Convert.ToChar(10)+Convert.ToChar(13)+"my string is link this..."+Convert.ToChar(10)+Convert.ToChar(13)+"Code"+Convert.ToChar(10)+Convert.ToChar(13)+Convert.ToChar(10)+Convert.ToChar(13)+"and i want to show like that";
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
I created an OL 2003 VSTO Addin in C#. I used the NewInspector event to add a toolbar whenever a Mail is opened.
It works fine when i open a Mail in Outlook (e.g. New) or when i create the mail via the contextmenu in Windows Explorer.
But the event doesn´t fire, when i create a new Mail via Excel (File - send to - E Mail attachement).
How can i solve the problem?
Any Help will be appreciated
EisMayer
|
|
|
|
|
How do i calculate subtitems[4] * subtitems[5] + next item to a label..
like this:
(subtitems[0]),subtitems[1],subtitems[2],subtitems[3], 3.5, 100
(subtitems[0]),subtitems[1],subtitems[2],subtitems[3], 3.5, 100
awnser should be = 700..
tnx
|
|
|
|
|
You have to convert the subitems to numbers before you can carry out a calcualtion.
|
|
|
|
|
How, can you give me a example??
i´m pretty new on c#
can you give me a little code
tnx
Best regards
//André
|
|
|
|
|
I'm always concerned by people who are attempting to write complex code, but have not taken the time to learn how to do trivial, core stuff. Have you thought about learning C# before you play with windows forms ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
int.TryParse is how to turn the strings into numbers, the rest should be obvious.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Is the Shared Add-in template available for the Visual Studio 2005 Express Edition? If so where would I find the Shared Add-in template?
Thanks,
Chad Dolan
|
|
|
|
|
Nope. Professional and above only.
|
|
|
|
|
Dave,
Thanks for the information. I thought that was going to be the answer but I need to double check.
Thanks,
Chad Dolan
|
|
|
|
|
I do not believe that the Express Edition support Add-ins.
|
|
|
|
|
Joseph,
Thanks for helping me out. I figured that the Express Edition did not support Add-ins but I had to make sure.
Thanks,
Chad Dolan
|
|
|
|