TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
christian
NA
1
0
C# and console
Sep 5 2008 12:15 PM
Hi,
I am writing a small console application in which I instantiate a new object and add an event listener to it. My goal is now to wait and sit there until such an event occurs, in which case my listener gets called.
My problem is: how do I implement that? Clearly, if I just add my listener to the object, my program will terminate after that. It seems that adding an infinite loop after that doesn't work (blocking?), so I was thinking of using threads. My initial attempt didn't prove successful, though.
Anybody knows how to do this? It's a very unambitious goal and I am sure there must be a way. By the way, it's about Microsoft Speech API (SAPI) and the event listener here is the callback function that is called whenever sth was recognized.
Here is the code skeleton:
class Program {
// Declaration for variables
...
public void init()
{
//Initialize object
objRecoContext = new SpeechLib.SpSharedRecoContext();
...
// Add listener
objRecoContext.Recognition += new
_ISpeechRecoContextEvents_RecognitionEventHandler(handleRecognition);
}
public void handleRecognition(...)
{
System.console.WriteLine("Got it");
}
public static void Main()
{
Program p = new Program();
p.init();
}
}
I would be really glad for any help.
Thanks!
Reply
Answers (
2
)
Checking to see if an Array has data
How do I remove the MainReport Tab from CrystalReportViewer?