Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8186599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:15:55+00:00 2026-06-07T02:15:55+00:00

I founded some code to correctly shutdown java application from C# console application, using

  • 0

I founded some code to correctly shutdown java application from C# console application, using InputSimulator but when i tried it, it didnt give me an expected result.

When i close my java application using keyboard CTRL-C

...
[INFO] 2012-07-03 19:29:36 - Packet: [C] 0x02
[INFO] 2012-07-03 19:29:40 - Shutdown hook raised, shutting down...
[INFO] 2012-07-03 19:29:45 - All data saved. Good luck!

When i close my java application using InputSimulator

Full thread dump Java HotSpot(TM) Client VM (20.6-b01 mixed mode):

“DestroyJavaVM” prio=6 tid=0x4b524000 nid=0x6f4 waiting on condition
[0x00000000 ] java.lang.Thread.State: RUNNABLE

“Thread-1” prio=6 tid=0x4b523800 nid=0x65c waiting on condition
[0x4cd0f000] java.lang.Thread.State: TIMED_WAITING (sleeping)
at java.lang.Thread.sleep(Native Method)
at gameserver.utils.DeadlockDetector.run(DeadlockDetector.java:76)
at java.lang.Thread.run(Unknown Source)

“server-rdc-acceptor” prio=6 tid=0x4b523000 nid=0x102c runnable
[0x4cc7f000] java.lang.Thread.State: RUNNABLE
at sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(Native Method)
at sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(Unknown Source)
at sun.nio.ch.WindowsSelectorImpl$SubSelector.access$400(Unknown Source)

    at sun.nio.ch.WindowsSelectorImpl.doSelect(Unknown Source)
    at sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source)
    - locked <0x3e057ef0> (a sun.nio.ch.Util$2)
    - locked <0x3e057ee0> (a java.util.Collections$UnmodifiableSet)
    - locked <0x3e057cc0> (a sun.nio.ch.WindowsSelectorImpl)
    at sun.nio.ch.SelectorImpl.select(Unknown Source)
    at sun.nio.ch.SelectorImpl.select(Unknown Source)
    at commons.ngen.network.Acceptor.run(Acceptor.java:259)

My InputSimulator using:

private void StartServer()
{

                ProcessStartInfo info = new ProcessStartInfo();
                info.UseShellExecute = false;
                info.FileName = "java"
                info.Arguments = "-Xms512m -Xmx1024m server.jar gameserver.Server"
                ServerProcess = new Process();
                ServerProcess.StartInfo = info;
                ServerProcess.Start();

                Thread.Sleep(60000);
                CloseCorrectly(ServerProcess);
}

private void CloseCorrectly(Process pr)
{
  IntPtr hWnd = pr.MainWindowHandle;
  if (hWnd != null)
            {
                    SetForegroundWindow(hWnd);
                    Thread.Sleep(1000);
                    InputSimulator f = new InputSimulator();

                    f.Keyboard.ModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.CANCEL);

                Thread.Sleep(1000);
            }
}

What i’m doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T02:15:57+00:00Added an answer on June 7, 2026 at 2:15 am

    The homepage (http://inputsimulator.codeplex.com/) suggests that ctrl-C qould be done via:

    InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_C);
    

    The docs don’t suggest what cancel is but fortunately JamesB has bravely searched the source to find that it refers to break.

    Try the above code and that should hopefully simulate a real ctrl-c.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use the facebook in my application. I had founded some
I'm using ajax in my website to call some information from a UserControl called
I want to get some data from companies' Facebook pages, but I don't know
While using some of the DateTime Function's at local machine ,later i founded out
I have the following text pattern, os2v some text openssl-56 test Is Not founded
How can I get exit code of wget from the subshell process? So, main
During a code review, a senior dev commented on some nesting I had going
please help me. I want to print some reports from .NET app. I read
In my app when i do some long work i'm using a Progress Dialog
I found useful in some situation to use Instruments for memory leaks. But some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.