Keyboard reading in console applications

I'm writing a console application as part of a college course. Up until now I've been using the cs1.Keyboard package that is widely available to newbies.
Trouble is that it requires "enter" to be typed after anything before it registers any of the keystrokes.
I want a method that will just simply wait for a keypress and return the char when one happens.
I understand that this could be done with an eventListener in an applet, but can it be done in a console application? and if so how?
cheers
Mark

The thing you are asking for would require ioctl calls to alter the console's
TTY configuration. This functionality is not implemented in Java. The JNI
call is the only solution (probably an overkill for such a simple thing).
I suggest that you move to GUI or accept the workaround (i.e require users
to type ENTER after each input)

Similar Messages

  • Read only access to Console Application ...

    We have deployed development best practice examples in one WLS instance. So, all
    developer can run our sample examples. All developer doesn't have admin privileges.
    Some times, developer would like to get "READ ONLY " access to console application.
    They can see JDBC / JMS / connection pool information.
    Is it possible to allow READ ONLY Access to CONSOLE application ?
    TIA
    Wlstech

    I don't think this is possible in the current release.
    Kumar
    "Wlstech" <[email protected]> wrote in message
    news:3af30e21$[email protected]..
    >
    We have deployed development best practice examples in one WLS instance.So, all
    developer can run our sample examples. All developer doesn't have adminprivileges.
    Some times, developer would like to get "READ ONLY " access to consoleapplication.
    They can see JDBC / JMS / connection pool information.
    Is it possible to allow READ ONLY Access to CONSOLE application ?
    TIA
    Wlstech

  • How to hide keyboard input in a Java console application?

    I am developing a console application that request a password, but I don't wanna the password to be shown in the console when the user enters it.
    The source code is something like that:
    System.out.print("Password: ");
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in)) ;
    String password = "";
    try
           password  = in.readLine() ;
    catch (IOException e) {}
    return s ;

    Moderator advice: Please don't post in threads that are long dead and don't hijack another poster's thread. When you have a question, start your own topic. Feel free to provide a link to an old post that may be relevant to your problem.
    Moderator action: Locking this thread.
    Moreover, your question is answered in this thread. Didn't you at least read it before resurrecting it?
    db

  • Getting error while creating SPSite object in console application

    Hi,
    I am getting error "The Web application at
    http://myWebApp/sites/siteCol could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application." whenever
    I try to execute the below code in my console application.
    SPSite oSite = new SPSite("sitecolUrl");
    I tried to change the platform target to AnyCpu,
    I tried to wrap it with SP.RunWithElevatedPrivileges
    but all above didn't solve the error.
    Any suggestions?

    Hello,
    instead of targetting "any cpu" target x64 and be sure to target .net 3.5 (I made a post about it it could help you
    http://christopherclementen.wordpress.com/2012/03/02/windows-application-spsite-filenotfound/
    Best regards, Christopher.
    Blog |
    Mail
    Please remember to click "Mark As Answer" if a post solves your problem or
    "Vote As Helpful" if it was useful.
    Why mark as answer?

  • Getting Error while Execute SSIS Package from Console Application

    Dear All,
    SSIS package working fine directly.
    I got following error while execute SSIS package from C# console application.
    The connection "{79D920D4-9229-46CA-9018-235B711F04D9}" is not found. This error is thrown by Connections collection when the specific connection element is not found.
    Cannot find the connection manager with ID "{79D920D4-9229-46CA-9018-235B711F04D9}" in the connection manager collection due to error code 0xC0010009. That connection manager is needed by "OLE DB Destination.Connections[OleDbConnection]"
    in the connection manager collection of "OLE DB Destination". Verify that a connection manager in the connection manager collection, Connections, has been created with that ID.
    OLE DB Destination failed validation and returned error code 0xC004800B.
    One or more component failed validation.
    There were errors during task validation.
    Code : 
       public static string RunDTSPackage()
                Package pkg;
                Application app;
                DTSExecResult pkgResults;
                Variables vars;
                app = new Application();
                pkg = app.LoadPackage(@"D:\WORK\Package.dtsx", null);
         Microsoft.SqlServer.Dts.Runtime.DTSExecResult results = pkg.Execute();
    I have recreate the application with again new connection in SSIS.
    Still not working, Please provide solution if any one have.
    DB : SQL Server 2008 R2
    Thanks and regards,
    Hardik Ramwani

    The connection "{79D920D4-9229-46CA-9018-235B711F04D9}" is not found. This error is thrown by Connections collection when the specific connection element is not found.
    Cannot find the connection manager with ID "{79D920D4-9229-46CA-9018-235B711F04D9}" in the connection manager collection due to error code 0xC0010009. That connection manager is needed by "OLE DB Destination.Connections[OleDbConnection]"
    in the connection manager collection of "OLE DB Destination". Verify that a connection manager in the connection manager collection, Connections, has been created with that ID.
    Are you sure that you are running the same package via .NET which works fine from Visual Studio?
    By reading error message, I can say that you have copied OLEDB task from another package OR you have deleted one OLEDB connection manager. Now when package is run this task tries to use the connection manager and not found thus throws error message.
    Open all OLEDB destination tasks and you find connection manager missing. Connection Manager name should be provided there
    Cheers,
    Vaibhav Chaudhari
    MCSA - SQL Server 2012

  • C# console application closes on it's own as soon as it opens

    Hello to all of you.
    I know this is a very common problem but there seems to be no solution for me so far.
    The known problem that right after build and start debugging, terminal opens and closes like a flush.
    Have Tried the below already:
    Console.ReadLine();
    Console.ReadKey();
    System.Console.ReadLine();
    System.Console.ReadKey();
    Ctrl+F5
    Start without debugging
    and a couple more.
    Went to settings to see if console application was enabled (which it was).
    It was working fine until this noon,when I was working on my exercise and using always "Console.ReadLine();" in order for the window to
    remain open, but all of the sudden it did not work for me anymore.
    I have to say at this point that not a single change was done in my laptop. I also restarted just in case, but nothing's changed.
    Furthermore I use version VS express windows desktop 2013 with update 4 and also Vs express windows 2013 with update 4.
    Please help me and thank you very much for taking the time to read this.

    I know this is a very common problem but there seems to be no solution for me so far.
    The known problem that right after build and start debugging, terminal opens and closes like a flush.
    Have Tried the below already:
    Console.ReadLine();
    Console.ReadKey();
    System.Console.ReadLine();
    System.Console.ReadKey();
    Ctrl+F5
    Start without debugging
    and a couple more.
    It was working fine until this noon,when I was working on my exercise and using always "Console.ReadLine();" in order for the window to
    remain open, but all of the sudden it did not work for me anymore.
    Is the code you're trying to debug in a source code file which is specified as part of the
    project being built/run?
    A common mistake is to open a new source code file in the IDE, add code, then try to run
    or debug it. If the new source code file isn't listed as part of the active project
    in
    the Solution Explorer window, then it will not get compiled and added to the project's
    target (.exe). So what gets executed/run doesn't include the code on the screen in the
    IDE editor.
    - Wayne

  • New install of VS 2013 on new Windows 8.1 PC, simplest C++ 64-bit console application, unable to bind breakpoints

    Hi,
        I have a new Dell Desktop PC, running Windows 8.1.  I have a fresh install of VS 2013 Professional, I created the simplest C++ console application.  If I set the breakpoints before debug starts, everything is fine. but
    once inside a debug session, I can't not set any breakpoints anyway, it keeps give me the "The following breakpoint cannot be set: At xxx.cpp, line 19, The breakpoint failed to bind."  It seems the debugger wasn't able to load the symbols correctly,
    but the output windows looks all right.
        Can anyone please help?  I can't do any debugging now...  Thanks!  My email [email protected]
     SaveDir.exe D:\Temp\x64\Debug\SaveDir.exe N/A Yes Symbols loaded. D:\Temp\x64\Debug\SaveDir.pdb 1  2/14/2015 9:25 AM 00007FF6837B0000-00007FF684200000 [13964] SaveDir.exe  
     ntdll.dll C:\Windows\System32\ntdll.dll N/A No Symbols loaded.  2 6.3.9600.17630 (winblue_r7.150109-2022) 1/10/2015 4:23 PM 00007FF881B70000-00007FF881D1C000 [13964] SaveDir.exe  
     kernel32.dll C:\Windows\System32\kernel32.dll N/A No Symbols loaded.  3 6.3.9600.17056 (winblue_gdr.140319-1520) 3/20/2014 9:17 AM 00007FF880F50000-00007FF88108A000 [13964] SaveDir.exe  
     KernelBase.dll C:\Windows\System32\KernelBase.dll N/A No Symbols loaded.  4 6.3.9600.17278 (winblue_r2.140815-1500) 8/16/2014 10:17 AM 00007FF87EED0000-00007FF87EFDF000 [13964] SaveDir.exe  

    Hi,
        I have a new Dell Desktop PC, running Windows 8.1.  I have a fresh install of VS 2013 Professional, I created the simplest C++ console application.  If I set the breakpoints before debug starts, everything is fine. but
    once inside a debug session, I can't not set any breakpoints anyway, it keeps give me the "The following breakpoint cannot be set: At xxx.cpp, line 19, The breakpoint failed to bind."  It seems the debugger wasn't able to load the symbols correctly,
    but the output windows looks all right.
        Can anyone please help?  I can't do any debugging now...  Thanks!  My email [email protected]
     SaveDir.exe D:\Temp\x64\Debug\SaveDir.exe N/A Yes Symbols loaded. D:\Temp\x64\Debug\SaveDir.pdb 1  2/14/2015 9:25 AM 00007FF6837B0000-00007FF684200000 [13964] SaveDir.exe  
     ntdll.dll C:\Windows\System32\ntdll.dll N/A No Symbols loaded.  2 6.3.9600.17630 (winblue_r7.150109-2022) 1/10/2015 4:23 PM 00007FF881B70000-00007FF881D1C000 [13964] SaveDir.exe  
     kernel32.dll C:\Windows\System32\kernel32.dll N/A No Symbols loaded.  3 6.3.9600.17056 (winblue_gdr.140319-1520) 3/20/2014 9:17 AM 00007FF880F50000-00007FF88108A000 [13964] SaveDir.exe  
     KernelBase.dll C:\Windows\System32\KernelBase.dll N/A No Symbols loaded.  4 6.3.9600.17278 (winblue_r2.140815-1500) 8/16/2014 10:17 AM 00007FF87EED0000-00007FF87EFDF000 [13964] SaveDir.exe  
    Hello,
    >> If I set the breakpoints before debug starts, everything is fine. but once inside a debug session, I can't not set any breakpoints anyway, it keeps give me the "The following breakpoint cannot be set: At xxx.cpp, line 19, The breakpoint
    failed to bind." 
    >> I created the simplest C++ console application. 
    Since it is a simple console application, would you mind sharing us that sample and the steps to reproduce this issue? We will test it on ourside.
    To confirm whether this issue is related to visual studio, you could test it in another machine which also insatlled VS2013 to test.
    In addition, before you test it in another machine, I would recommend you make sure whether you have installed the latest update for VS2013.
    Regards,
    Carl
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Which is better approach to manage sharepoint online - PowerShell Script with CSOM or Console Application with CSOM?

    Which is better approach to manage sharepoint online - PowerShell Script with CSOM or Console Application with CSOM?
    change in sharepoint scripts not require compilation but anything else?

    Yes, PowerShell is great, since you can quick change your code without compilation.
    SP admin can write ps scripts without specific tools like Visual Studio.
    With powershell you can use cmdlets,
    which could remove a lot of code, for example restarting a service.
    [custom.development]

  • Update-Help error when console application is run in remote machine via PS remoting

    Hello,
    When I execute a particular console application in a remote machine via PS remoting, I get an error related to update-help. When I execute it directly on the remote machine, it works...
    My code:
    $credential = Get-Credential -Credential "DomainName\AccountName"
    $session = New-PSSession -ComputerName "MachineName" -Authentication Credssp -Credential $credential;
    Invoke-Command -session $session -ScriptBlock {
    try{
    cd <network share location>
    .\theConsoleApp.exe | Out-File C:\console-output.txt
    $error | Out-File C:\console-error-output.txt
    $exitCode
    } catch {
    throw $error
    Error seen in the console:
    NetNat, PcsvDevice, PSDesiredStateConfiguration, SoftwareInventoryLogging, StartScreen, TLS, WindowsSearch' with UI culture(s) {en-US} : Unable to retrieve the HelpInfo XML file for
    UI culture en-US. Make sure the HelpInfoUri property in the module manifest is valid or check your network connection and then try the command again.
    $error variable from above:
    Errored out (exit code 1603) with error message: ErrorId 10010: Xpatch threw an unexpected exception: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
    I’ve tried
    two different user accounts
    multiple file share locations
    different OSs
    different target servers
    but have not determined the cause of the error.
    I would appreciate any help on this.
    -Rohan.

    Clearly the remote EXE cannot run in that context.  YOU should not run that program remotely.
    I suspect there is also information you are not giving to us.
    ¯\_(ツ)_/¯

  • How to start a Kinect v2 in a C++ Console Application?

    Hello,
    I am fairly new at this, I only have basic C++ experience just making console applications. My question is, is there any way to get a console application working with Kinect 2.0. I was reading the Programming Guide on MSDN for the Kinect v2, but
    the code seems to be completely different in the samples provided. I cannot seem to link Visual Studio with the Kinect Sensor, Visual Studio does not pick up the #include header files. Help!

    There are ways, but you still need to use the COM api's provided by the SDK. The code is the same whether using D2D or Win32 for c++. Have a look at the sample code to get started. Most of the samples using a polling mechanism which should work
    for most console applications.
    If you want a more simplified (flat c) based api, you might want to try Kinect Common Bridge(KCB) as a wrapper around the core SDK.
    https://github.com/MSOpenTech/KinectCommonBridge/tree/2.0
    Carmine Sirignano - MSFT

  • Which solution is better for schedules task? Console application or windows service?

    I have a "MULTI-LEVEL" XML file that I will be getting on daily basis and I want to accomplish following tasks:
    1) I have to read and parse the "MULTI-LEVEL" XML data
    2) Then I have to set or create some kind of .net service (c#) that read the xml and parse the data once a day (daily)?
    3) Now I have SOAP service from other software where I want to feed this XML data to. The schedules service will compare the XML data with software data and update (or add) based on the comparision.
    For this task, I come to conclusion that there are 2 best ways to do this:
    1) Create a console application and use windows task scheduler to run it everyday
    2) Create a windows service that runs in the background
    Which is a better way (or reliable)  solution to do this task? Please advise

    There are several things to keep in mind when writing an app that is designed to run without a user logged in. One of the most common mistakes is requiring some sort of user input.  Since the task will run without user intervention you don't want
    any sort of calls to Console.ReadLine, MessageBox.Show, etc.  They will cause the task to freeze and eventually need to be terminated.  You also don't want to rely on any sort of desktop apps running since a user may or may not be logged on at the
    time.
    Also be aware that a task can be scheduled to run under any user context.  As such you either need to ensure it runs under an account with sufficient privileges or that your app needs no special privileges.  You mentioned you tried to run it from
    bin\debug but you most likely have your project under your Documents directory.  Only you would have permissions to that folder and therefore will run into issues if the task is run under a different context.  You also mentioned you put it in the
    C:\ but users don't have write privileges to that folder and therefore if you tried to write a file out it would fail. If you need to read/write files then you should pick a common location that all users have access to or at least the one that will run the
    scheduled task. Be aware that, by default, Task Scheduler will not run a task elevated. You need to check the option to run elevated when you configure the user to run the task under.
    One of the key things to ensure you do with a task is verify it is working properly as a normal app.  You should also ensure that you have good logging so that if it does fail you can trace down the failure more easily.  One common thing that people
    tend to do in console apps is put a try-catch around the main function and display a message if an unhandled exception occurs. This is going to cause problems in a task.  Simply log the exception and rethrow it so Task Scheduler will flag the run as a
    failure.
    If you still cannot figure out why your task is failing then please add some logging and then tell us what code is being run at the time and what the failure is.

  • Use sql notification for console application C#

    I have developed ucma C# console application which sends IM  to users. 
    Now I want to send IM if any new entry is added in the table 
    So i want to use query notification .
    I have enabled service broker on my database .
    And I have added code for sqldepedency  in my code file.
    as follows.
    public static void Main(string[] args)
    UCMASampleInstantMessagingCall ucmaSampleInstantMessagingCall =
    new UCMASampleInstantMessagingCall();
    ucmaSampleInstantMessagingCall.connectionfunction();
    public void connectionfunction()
    string connectionString = @"Data Source=PIXEL-IHANNAH2\PPINSTANCE;User ID=sqlPPUser;Password=ppuser1;Initial Catalog=Ian;";
    SqlDependency.Stop(connectionString);
    SqlConnection sqlConnection = new SqlConnection(connectionString);
    string statement = "select * from dbo.tblTest";
    SqlCommand sqlCommand = new SqlCommand(statement, sqlConnection);
    // Create and bind the SqlDependency object to the command object.
    SqlDependency dependency = new SqlDependency(sqlCommand, null, 0);
    SqlDependency.Start(connectionString);
    dependency.OnChange += new OnChangeEventHandler(dependency_OnChange);
    private void dependency_OnChange(object sender, SqlNotificationEventArgs e)
    ucmaSampleInstantMessagingCall.run()
    private void Run() { // Initialize and startup the platform. Exception ex = null; try { // Create the UserEndpoint _helper = new UCMASampleHelper(); _userendpoint = _helper.CreateEstablishedUserEndpoint();
    Now I want to run this application in the background , so f any new entry is added it will notify my C# application and call run function.
    i tried above code but it was not working.
    Sample code is avaliableon net but it is for form application and we can see output if we run the form application .
    so if i want to run my C# application what should I do?

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Configuration;
    using System.Security.Principal;
    using System.Security.Cryptography.X509Certificates;
    using System.Net;
    using System.Threading;
    using System.Diagnostics;
    using Microsoft.Rtc.Collaboration;
    using Microsoft.Rtc.Signaling;
    using System.Runtime.InteropServices;
    //using Microsoft.Rtc.Collaboration.Sample.Common;
    namespace UserPresence
    class UCMASampleInstantMessagingCall
    #region Locals
    // The information for the conversation and the far end participant.
    // Subject of the conversation; will appear in the center of the title bar of the
    // conversation window if Microsoft Lync is the far end client.
    private static String _conversationSubject = "The Microsoft Lync Server!";
    // Priority of the conversation will appear in the left corner of the title bar of the
    // conversation window if Microsoft Lync is the far end client.
    private static String _conversationPriority = ConversationPriority.Urgent;
    // The Instant Message that will be sent to the far end.
    private static String _messageToSend = "Hello World! I am a bot, and will echo whatever you type. " +
    "Please send 'bye' to end this application.";
    private InstantMessagingCall _instantMessaging;
    private InstantMessagingFlow _instantMessagingFlow;
    //private ApplicationEndpoint _applicationEndpoint;
    private UserEndpoint _userendpoint;
    private UCMASampleHelper _helper;
    private static SqlDependency dependency;
    private static string connectionString = @"Data Source=MyServer;Initial Catalog=MyDatabase;Integrated Security=SSPI";
    // Event to notify application main thread on completion of the sample.
    private AutoResetEvent _sampleCompletedEvent = new AutoResetEvent(false);
    #endregion
    #region Methods
    /// <summary>
    /// Instantiate and run the InstantMessagingCall quickstart.
    /// </summary>
    /// <param name="args">unused</param>
    //private string _helper;
    //UCMASampleHelper _helper = new UCMASampleHelper();
    public static void Main(string[] args)
    UCMASampleInstantMessagingCall ucmaSampleInstantMessagingCall =
    new UCMASampleInstantMessagingCall();
    var connection = new SqlConnection(connectionString);
    SqlDependency.Start(connectionString);
    SqlConnection connection = new SqlConnection(connectionString);
    connection.Open();
    SqlCommand command = new SqlCommand(
    "select col1 from dbo.tblTest",
    connection);
    // Create a dependency (class member) and associate it with the command.
    dependency = new SqlDependency(command, null, 5);
    // Subscribe to the SqlDependency event.
    dependency.OnChange += new OnChangeEventHandler(onDependencyChange);
    // start dependency listener
    SqlDependency.Start(connectionString);
    //ucmaSampleInstantMessagingCall.Run();
    private static void onDependencyChange(Object o, SqlNotificationEventArgs args)
    run();
    private void Run()
    // Initialize and startup the platform.
    Exception ex = null;
    try
    // Create the UserEndpoint
    _helper = new UCMASampleHelper();
    _userendpoint = _helper.CreateEstablishedUserEndpoint();
    Console.Write("The User Endpoint owned by URI: ");
    Console.Write(_userendpoint.OwnerUri);
    Console.WriteLine(" is now established and registered.");
    List<string> _Users = new List<string>();
    _Users.Add("sip:[email protected]");
    _Users.Add("sip:[email protected]");
    foreach (string useruri in _Users)
    // Setup the conversation and place the call.
    ConversationSettings convSettings = new ConversationSettings();
    convSettings.Priority = _conversationPriority;
    convSettings.Subject = _conversationSubject;
    // Conversation represents a collection of modes of communication
    // (media types)in the context of a dialog with one or multiple
    // callees.
    //Convers conver =new ConversationParticipant
    Conversation conversation = new Conversation(_userendpoint, convSettings);
    InstantMessagingCall _instantMessaging = new InstantMessagingCall(conversation);
    // Call: StateChanged: Only hooked up for logging. Generally,
    // this can be used to surface changes in Call state to the UI
    _instantMessaging.StateChanged += this.InstantMessagingCall_StateChanged;
    // Subscribe for the flow created event; the flow will be used to
    // send the media (here, IM).
    // Ultimately, as a part of the callback, the messages will be
    // sent/received.
    _instantMessaging.InstantMessagingFlowConfigurationRequested +=
    this.InstantMessagingCall_FlowConfigurationRequested;
    // Get the sip address of the far end user to communicate with.
    //String _calledParty = "sip:" +
    // UCMASampleHelper.PromptUser(
    // "Enter the URI of the user logged onto Microsoft Lync, in the User@Host format => ",
    // "RemoteUserURI");
    // Place the call to the remote party, without specifying any
    // custom options. Please note that the conversation subject
    // overrides the toast message, so if you want to see the toast
    // message, please set the conversation subject to null.
    // _instantMessaging.Conversation()
    _instantMessaging.BeginEstablish(useruri, new ToastMessage("Hello Toast"), null,
    CallEstablishCompleted, _instantMessaging);
    catch (InvalidOperationException iOpEx)
    // Invalid Operation Exception may be thrown if the data provided
    // to the BeginXXX methods was invalid/malformed.
    // TODO (Left to the reader): Write actual handling code here.
    ex = iOpEx;
    finally
    if (ex != null)
    // If the action threw an exception, terminate the sample,
    // and print the exception to the console.
    // TODO (Left to the reader): Write actual handling code here.
    Console.WriteLine(ex.ToString());
    Console.WriteLine("Shutting down platform due to error");
    _helper.ShutdownPlatform();
    // Wait for sample to complete
    _sampleCompletedEvent.WaitOne();
    // Just to record the state transitions in the console.
    void InstantMessagingCall_StateChanged(object sender, CallStateChangedEventArgs e)
    Console.WriteLine("Call has changed state. The previous call state was: " + e.PreviousState +
    "and the current state is: " + e.State);
    // Flow created indicates that there is a flow present to begin media
    // operations with, and that it is no longer null.
    public void InstantMessagingCall_FlowConfigurationRequested(object sender,
    InstantMessagingFlowConfigurationRequestedEventArgs e)
    Console.WriteLine("Flow Created.");
    _instantMessagingFlow = e.Flow;
    // Now that the flow is non-null, bind the event handlers for State
    // Changed and Message Received. When the flow goes active,
    // (as indicated by the state changed event) the program will send
    // the IM in the event handler.
    _instantMessagingFlow.StateChanged += this.InstantMessagingFlow_StateChanged;
    // Message Received is the event used to indicate that a message has
    // been received from the far end.
    _instantMessagingFlow.MessageReceived += this.InstantMessagingFlow_MessageReceived;
    // Also, here is a good place to bind to the
    // InstantMessagingFlow.RemoteComposingStateChanged event to receive
    // typing notifications of the far end user.
    _instantMessagingFlow.RemoteComposingStateChanged +=
    this.InstantMessagingFlow_RemoteComposingStateChanged;
    private void InstantMessagingFlow_StateChanged(object sender, MediaFlowStateChangedEventArgs e)
    Console.WriteLine("Flow state changed from " + e.PreviousState + " to " + e.State);
    // When flow is active, media operations (here, sending an IM)
    // may begin.
    if (e.State == MediaFlowState.Active)
    // Send the message on the InstantMessagingFlow.
    _instantMessagingFlow.BeginSendInstantMessage(_messageToSend, SendMessageCompleted,
    _instantMessagingFlow);
    private void InstantMessagingFlow_RemoteComposingStateChanged(object sender,
    ComposingStateChangedEventArgs e)
    // Prints the typing notifications of the far end user.
    Console.WriteLine("Participant "
    + e.Participant.Uri.ToString()
    + " is "
    + e.ComposingState.ToString()
    private void InstantMessagingFlow_MessageReceived(object sender, InstantMessageReceivedEventArgs e)
    // On an incoming Instant Message, print the contents to the console.
    Console.WriteLine(e.Sender.Uri + " said: " + e.TextBody);
    // Shutdown if the far end tells us to.
    if (e.TextBody.Equals("bye", StringComparison.OrdinalIgnoreCase))
    // Shutting down the platform will terminate all attached objects.
    // If this was a production application, it would tear down the
    // Call/Conversation, rather than terminating the entire platform.
    _instantMessagingFlow.BeginSendInstantMessage("Shutting Down...", SendMessageCompleted,
    _instantMessagingFlow);
    _helper.ShutdownPlatform();
    _sampleCompletedEvent.Set();
    else
    // Echo the instant message back to the far end (the sender of
    // the instant message).
    // Change the composing state of the local end user while sending messages to the far end.
    // A delay is introduced purposely to demonstrate the typing notification displayed by the
    // far end client; otherwise the notification will not last long enough to notice.
    _instantMessagingFlow.LocalComposingState = ComposingState.Composing;
    Thread.Sleep(2000);
    //Echo the message with an "Echo" prefix.
    _instantMessagingFlow.BeginSendInstantMessage("Echo: " + e.TextBody, SendMessageCompleted,
    _instantMessagingFlow);
    private void CallEstablishCompleted(IAsyncResult result)
    InstantMessagingCall instantMessagingCall = result.AsyncState as InstantMessagingCall;
    Exception ex = null;
    try
    instantMessagingCall.EndEstablish(result);
    Console.WriteLine("The call is now in the established state.");
    catch (OperationFailureException opFailEx)
    // OperationFailureException: Indicates failure to connect the
    // call to the remote party.
    // TODO (Left to the reader): Write real error handling code.
    ex = opFailEx;
    catch (RealTimeException rte)
    // Other errors may cause other RealTimeExceptions to be thrown.
    // TODO (Left to the reader): Write real error handling code.
    ex = rte;
    finally
    if (ex != null)
    // If the action threw an exception, terminate the sample,
    // and print the exception to the console.
    // TODO (Left to the reader): Write real error handling code.
    Console.WriteLine(ex.ToString());
    Console.WriteLine("Shutting down platform due to error");
    _helper.ShutdownPlatform();
    private void SendMessageCompleted(IAsyncResult result)
    InstantMessagingFlow instantMessagingFlow = result.AsyncState as InstantMessagingFlow;
    Exception ex = null;
    try
    instantMessagingFlow.EndSendInstantMessage(result);
    Console.WriteLine("The message has been sent.");
    catch (OperationTimeoutException opTimeEx)
    // OperationFailureException: Indicates failure to connect the
    // IM to the remote party due to timeout (called party failed to
    // respond within the expected time).
    // TODO (Left to the reader): Write real error handling code.
    ex = opTimeEx;
    catch (RealTimeException rte)
    // Other errors may cause other RealTimeExceptions to be thrown.
    // TODO (Left to the reader): Write real error handling code.
    ex = rte;
    finally
    // Reset the composing state of the local end user so that the typing notifcation as seen
    // by the far end client disappears.
    _instantMessagingFlow.LocalComposingState = ComposingState.Idle;
    if (ex != null)
    // If the action threw an exception, terminate the sample,
    // and print the exception to the console.
    // TODO (Left to the reader): Write real error handling code.
    Console.WriteLine(ex.ToString());
    Console.WriteLine("Shutting down platform due to error");
    _helper.ShutdownPlatform();
    #endregion
    So i want to call run method when new entry is added in the database . and this application is not like any asp.net form application . In form application we display data when programs loads as like your RefreshDataWithSqlDependency
    function . But in my application my application will run (send IM) when any new entry is added in the database . As I need running application to achieve notification , what kind of changes are required?

  • Console Application to run with window open

    Hi Guys
    I have a Console Application that I wrote and it working perfectly when I run it manually. It can create report using Crystal Reports, exports to PDF and then print.
    My challenge was when I ran it as a task, the reports are created but its not printing, my default PDF view is Adobe.
    How can I run my app with the Window open because I think that's causing it not to print
    Brian

    After doing some searches it turned out the issue I had was with Adobe Reader XI, when run from Task Manager it always gives problems so.
    I ended up using PDF XChange Viewer for printing and I can now print my PDFs with no Windows popoing up. I installed the free Viewer and call it from my code to print.
    Process.Start("C:\Program Files\Tracker Software\PDF Viewer\pdfxcview.exe", " /print:printer=""" & PrinterName & """ """ & pdfFileName & """")

  • Calling Console Application that uses WebBrowser from SQL Server - Not Running

    Hi there. I am working in a program automation that needs to get files from a website and put it in a database. It is done but as I need a console application and need webbrowser that comes from Windows Forms, I am trying to call it from the SQL Server using
    the xp_cmdshell but when it runs the .exe, it execute the block that is before the Application.Run() command but when it reaches this line, it stay running on Task manager but it not execute my code. How can I fix this? I had first created a Windows form application
    but it was not working anyway and then I tried a console application and then I use the [STAThread] and Application.Run(). At least it runs the file from SQL Server but is not executing all my code, I think that it stops on Application.Run() line. Any help
    will be very useful.
    Thanks for now.

    Thanks for the response. What I mean is that it just run the part of the code that is just using the Console, that's the code:
    // Main Method
    [STAThread]
    public static void Main()
    clearDatabase(myConnection);
    Console.Title = "Suframa Itens Robot";
    //If log file exists, it is deleted
    if ( File.Exists(@"suframaLog.txt") )
    File.Delete(@"suframaLog.txt");
    wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(loginWebsite);
    try
    //It is called as the program uses the WebBrowser Class from Windows Forms namespace
    //and it is a console Application
    Application.Run();
    catch ( Exception ex )
    Log(ex.Message);
    As you can see, I call a function on start named ClearDatabase, when I call the file from sql server it executes, the tables are cleared, but what I think is that the problem stop when reach the line Application.Run() as it is the line that allows the remaining
    code to execute as it uses events from WebBrowser class. 
    It is a program automation that needs to get a lot of files from a website that needs login and read line by line from the files and put on server, if I call it from the executable it runs fine, the only problem is when calling from SQL Server, Do you know
    how to fix this?
    Thanks.

  • How to use BundleTransformer in Console Application?

    Hi, I have a scss file (style.scss) and I want to transformer it to CSS using BundleTransformer.
    How to do it in a Console Application? I'm looking for example code or something like that :)

    Hi Shlomi,
    In my opinion, this thread is related to ASP.NET forum. So please post thread on that forum for more effective response. Thank you for understanding. Please refer to the following link.
    http://forums.asp.net/.
    Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

Maybe you are looking for

  • Error in Account determination for service vendor while posting miro

    Error in Account determination:Table T030 Key 1000 KDT                 Balance in Transaction currency Vendor currency is of INR

  • IDocs, INVOIC partner profile configuration

    Hi, I need to receive the INVOIC IDocs from sender system. Sender(S) system is new system receiver(R) system is already exisitng system. I tried to configure the inbound settings in receiver syste. But message type INVOIC, process code INVL, FM all a

  • Output of report to control file

    Hi all, I have to show my report output into 2 formats one is csv format and another is ctl file. For this I am using FND_SUBMIT.SET_REQUEST_SET in after report trigger of my report. For first output type I am submitting XML program to get csv output

  • 2 different sales org. for single plant and org.unit, can we?

    hi, we have this requirement to hava a 2 different sales org. for one single plant and one organization unit. is it possible just by assigning in spro path, spro-> CRM->master data->cross system assignment of organization units   <-| -> assign plant

  • Links without underlines

    Hey, Having a problem with CSS styles and using them to get rid of underlines in links.. Here's what we've tried so far... We've entered code into the <head> portion of code and after that there are no more links in the working part (Dreamweaver), bu