|
Thanks for your help. After taking a look at the information provided I got it.
|
|
|
|
|
Is it spinning inside the while loop while (mytrue)? Also how did you verify the server has shutdown?
|
|
|
|
|
1. You are checking if your current process has exited instead of checking if the process you are killing has exited or not.
2. You are not using the Process array you have created (in the code block posted). So why even retrieve it?
Following code might help you out:
Process[] processList = Process.GetProcessesByName("proccessName");
MessageBox.Show("Killing processes...");
try {
foreach (Process process in processList) {
process.Kill();
process.WaitForExit();
}
MessageBox.Show("Processes killed successfully.");
}
catch (Exception exception){
MessageBox.Show("Could not kill on of the processes.");
}
You can also use the other overload of WaitForExit and provide a suitable time out. In case you use that, then, after the call to the method, check if the process has exited and display the appropriate method if process is still running."No matter how many fish in the sea; it will be so empty without me." - From song "Without me" by Eminem
|
|
|
|
|
HELLO EVERYBODY,
I have a problem, I load a pdf in a webbrowser in Windows, in this event
string gcPthTMP = @"C:\TMP\";
string gcPthTrans = @"C:\TRANS\";
private void frmWebBrowser_Load(object sender, EventArgs e)
{
Uri uriPdf = new Uri(gcPthTMP + fileName);
this.webBrowser.Url = uriPdf;
}
This works fine, the problem is when I want to delete this file, i do:
private void frmWebBrowser_FormClosed(object sender, FormClosedEventArgs e)
{
this.webBrowser.Dispose();
this.Refresh();
System.Threading.Thread.Sleep(1000);
string fileName = this.txtUrl.Text.ToString().Trim();
this.Dispose(true);
if (System.IO.File.Exists(gcPthTMP + fileName))
{
System.IO.File.Delete(gcPthTMP + fileName);
}
}
this works fine in Vista, because delete the file without any problem, but the problem is in XP, this produce a error It says that the process is using by other process. Please help me, Ineed to solve this problem.
Thanks
|
|
|
|
|
why do you start a new thread?
why don't you reply to this[^]?
and why are you shouting the subject line?
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
Hello,
I trying puting a Thread
Thread tMosDocPdf = new Thread(new ThreadStart(DoShowPDF));
tMosDocPdf.Start();
when i load the file, but this dosen't works
After this in the event closed, i abort the Thread, but i obtain the same error, that I cant't dele this file because this is using for other process,
I think that the problem is with the plataform XP, because in Vista It woks fine
|
|
|
|
|
in addition to not responding to Luc's comments, you still havnt really made an attempt to find out whats locking the file on XP, have you ? (ie what proceses have the file) ..
until you do that, and we cant do it for you, I doubt anyone can suggest a solution
'g'
|
|
|
|
|
Garth J Lancaster wrote: until you do that, and we cant do it for you
True, and it funny how he thought of Luc's "forum thread" as a C# Thread
|
|
|
|
|
I'm not sure if it's possible but it would work if you can load it through a stream and close it before disposing the webbrowser object.
|
|
|
|
|
I already gave a tested solution on the older thread...
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
Hi,
I am using DAAB with stored procedures. I stored procedure is called from multiple functions.
Please guide how I can handle optional parameters with DAAB ? a stored procedure has 2 parameter and values are being passed by functiona1. In function2 I needed to declare 3rd parameter in same stored procedure. I set its default value (so that I may have not to pass it from function1) but even than functions1 stop working and show error message that no of parameters are not same.
I am just selecting data in stored procedure and I have not coded any set statement (like set ansi on or set norowcount) in it.
Please guide me.
thanks
|
|
|
|
|
If you do something like this in method1
<br />
SqlCommand.Parameters.Add( [param1] )<br />
SqlCommand.Parameters.Add( [param2] )<br />
SqlCommand.Execute...<br />
Then this in method2
<br />
SqlCommand.Parameters.Add( [param1] )<br />
SqlCommand.Parameters.Add( [param2] )<br />
SqlCommand.Parameters.Add( [param3] )<br />
SqlCommand.Execute...<br />
as long as SqlCommand is the same object in both methods, then of course calling method1 after method2 will produce this exception, because you do have too many parameters. I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Thanks for your kind attention.
I am not using command object. Rather I am passing parameters in directly in database object. e.g.
public int UpdateInvestmentObjectivesNExperience(CorporateAccount obj)
{
int result;
object objResult = db.ExecuteNonQuery("p_corporateaccount_InvestmentObjectivesNExperience", 2, obj .Id,
obj.SpecuativeGains, obj.HedgeAgainstInvestment, obj.InvestmentObjective,
obj.UndarstandNatureOfTCD, obj.UnderstandRiskOfTCD, obj.HaveExperienceOfTCD,
obj.NoOfMonthsExp, obj.TypesOfProductsDealtIn, obj.BrokersUsed, obj.WasAdviceReq,
obj.AvgTransationSize, obj.AvgNoOfTradesPerWeek);
result = Int32.Parse(objResult.ToString());
return result;
}
If I add a new parameter in stored procedure and set its default value by null or 1, than not only I will have to supply value for it in next functions where I am using it rather I will have to supply value for it in this method as well. (for the parameter that is last in stored procedure and has default value.)
Please guide.
thanks gain
|
|
|
|
|
If I understand what you are trying to accomplish then try this.
public int Foo(param1, param2)
{
return Bar(param1, param2, null);
}
public int Bar(param1, param2, param3)
{
return db.Execut(...);
} I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Thanks a lot for your kind attention and sharing.
I m exectly doing this now but I here is problem what I asked. On declaring a new parameter I will have to pass value for it in all above functions where even it is not being used.
I was surprised can there be some why I may have not change the code again and again.
thanks
|
|
|
|
|
You want to be able to write one method and never change it again even when you change the stored procedure?
public SqlCommand CreateProc(string procName, ReadOnlyCollection<DbParameter> parameters)
{
SqlCommand cmd = new SqlCommand(procName, SqlConnection);
cmd.CommandType = CommandType.StoredProcedure;
if(parameters != null)
{
foreach(DbParameter param in parameters)
{
cmd.Parameters.Add(param);
}
}
return cmd;
}
I know the language. I've read a book. - _Madmatt
modified on Monday, February 15, 2010 11:40 AM
|
|
|
|
|
Thanks for it.
Can you please explain a little more how it will helpful ? how I can use it ?
thanks
|
|
|
|
|
I thought it was pretty self-explanatory. What don't you understand? I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I have a combobox that I fill during the form load. That works fine. The question I have is how do I make it say "Select An Item to autofill" or whatever? I understand I could use selectedindex or something like that but the actually text i wish to display by default is not in the list.
thanks wasn't sure what to search for on this
|
|
|
|
|
I would just add it to the combo data list and then set it to be the selected value. Nothing fancy.
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
YEAH makes since to do it that way i guess, but the keywords are tied into each row on the database thats the only problem I have.modified on Sunday, February 14, 2010 3:46 AM
|
|
|
|
|
Hi, im just trying to send OSPF packets to a multicast IP address (224.0.0.5) but, usign raw sockets, windows 7 doesnt allow this type of sockets and using sharpcap i dont find the way to do that (send packets to a multicast ip address).
Please anyone who can help me ???
Im using C#......
|
|
|
|
|
When the connection between server and client break an event is raised,
I catch the event and null the client object but the client keeps on raising the event while it should be destroyed.
|
|
|
|
|
You did not post witch event so I am only guesing.
Maybe your event has e.Handled property. If so try setting it to true.
|
|
|
|
|
it's a custom event:
public delegate void kill(string msg);
public event kill Kill;
if (!clientSocket.Connected)
{
Kill("Server connection broken");
return;
}
Client clnt = null;
private void ms_Startclient_Click(object sender, EventArgs e)
{
if (ms_Startclient.Checked)
{
clnt = new Client();
clnt.Kill += new Client.kill(clnt_Kill);
}
else
{
clnt = null;
}
}
void clnt_Kill(string msg)
{
clnt = null;
MessageBox.Show(msg);
ms_Startclient.Checked = false;
}
|
|
|
|