Click here to Skip to main content
15,889,839 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I have created one on-screen keyboard with button click event..
This function is called or run onscreen key board.....
C#
private void loginControl1_btnOnScreenProcessKeyboardUser(object sender, EventArgs e)
       {
           if (p == null)
           {
               string Pproccename;
               pid = 0;
               p = System.Diagnostics.Process.Start("osk");
               pid = p.Id;
               Pproccename =  p.ProcessName.Trim();
           }
           else
           {
               p.Kill();
               p.Dispose();
               p = null;
           }
       }

Now I have closed that process with that function or that code
C#
 if (p1id > 0)
//if (p1 != null)
{
    p1.Kill();
    p1.Dispose();
    p1 = null;
}
else if (pid > 0)
// else if (p != null)
{
    p.Kill();
    p.Dispose();
    p = null;
}

It should work to close screen keyboard...
but when you click keyboard close directly then it gives error.. so tell me what should I do?
Give me answer...
Posted
Updated 23-Sep-10 0:16am
v2
Comments
Sandeep Mewara 23-Sep-10 6:16am    
What error?
DavidKiryazi 23-Sep-10 6:19am    
It is good you took time to at least include code, but I have no idea what's going on. The variables in the first code segment don't map to the second. Also, what happens if p1 and p are both created. How do you dispose them in the second segment? Or can it only be one or the other. Also, give us an idea of what the error is.

1 solution

Is the problem that you are killing a process even though it has closed its self down. If so check p.HasExited before calling kill;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900