|
Your code seems to work fine here - just your OrangeRed bar moves down as the rectagle gets bigger from the bottom - which looks a bit strange, but it is what your code asks.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Hi im new to c# and im building a program to telnet my server. Im trying to prevent the situation below
HostName> A command that will take a long time
The next command HostName>
Where the application sends the next command before the server has completed the last one .
Here is my code
public void Run(string cmd)
{
System.Threading.Thread.Sleep(300);
string lastCharacter = Status.Substring(Status.Length - 2, 1);
if (lastCharacter == ">")
{
WriteLine(cmd + "\n");
}
else
{
Run(cmd);
}
}
I want to get rid of the System.Threading.Thread.Sleep(); functions because they are a major source of exceptions in the program . Is there anyway to solve this problem without System.Threading.Thread.Sleep() and withut sucking up all the CPU time ?
|
|
|
|
|
I have a thread reading the responses and it doesn't signal the sending code until it sees the expected response.
This is done in a telnet scripting class I wrote, but which is not yet ready for distribution.
|
|
|
|
|
Hi everybody, im trying to execute a .jar file in my c# program, i have try several times and get examples, but i can't do it.
I execute in the cmd, like this
java -Xms60m -Xmx256m -jar C:\\Programming\\Interface.jar";
and this open the program.
But, trying with the Process class:
Process process = new Process();
System.Diagnostics.ProcessStartInfo procInfo =
new System.Diagnostics.ProcessStartInfo("java -Xms60m -Xmx256m -jar C:\\Programming\\Interface.jar");
process = System.Diagnostics.Process.Start(procInfo);
and other instructions, i get an exception, the file can't be found.
Some one knows??
Thanks in advance.
|
|
|
|
|
If you would read the parameter's name, you would see that it's called fileName, therefore - there is no file name called "java -Xm......". Try
<br />
Process proc = Process.Start("java", "-Xms60m...."); <br />
Also, make you that java exec is in your env path, otherwise supply full path to it.
|
|
|
|
|
Thanks for the answer dude, but it's not working still, i dont get an exception, just a ms-dos window for a second.
Process proc = Process.Start("java",
"java -Xms60m -Xmx256m -jar C:\\Programming\\Interface.jar");
proc.EnableRaisingEvents = false;
proc.WaitForExit();
Have i write it correctly? I really don't understand why waitForExit is neither working..
|
|
|
|
|
FINALLY IS WORKING!!! Here is the code, thanks for ur time..
string path = "C:\\Programming";
Process process = new Process();
process.EnableRaisingEvents = false;
process.StartInfo.FileName = "java.exe";
process.StartInfo.Arguments = "-jar " + '"' + path+ "\\interface.jar";
process.Start();
|
|
|
|
|
Hi,
Use the following code to run .jar file from c#
private int ExecuteProcess(string cmd, string cmdParams, string workingDirectory, int timeout, out string stdOutput)
{
using (Process process = Process.Start(new ProcessStartInfo(cmd, cmdParams)))
{
process.StartInfo.WorkingDirectory = workingDirectory;
//process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.Start();
stdOutput = process.StandardOutput.ReadToEnd();
process.WaitForExit(timeout);
return process.ExitCode;
}
}
string stdOutput;
string parameters = "Prajwal";
int exitCode = ExecuteProcess(@"C:\Program Files\Java\jre1.6.0\bin\Java.exe", " -jar samplejarfilename.jar " + parameters
,path, 5000, out stdOutput );
|
|
|
|
|
Dear All,
I have 2 problems with the software I am devoloping.
1. Through data reader it gets data from As400 and inserts it into a local database. I have label that is supposed to notify regarding the status of the process. But its text does not change at all untill data is inserted into local access file. There are several commands to change the text between.
2. Do you have any idea how to get the completion rate of the inserting process?
Thanks in advance
|
|
|
|
|
Ersan Ercek wrote: There are several commands to change the text between
Are you changing th text using a seperate thread?
Ersan Ercek wrote: Do you have any idea how to get the completion rate of the inserting process?
Well, there is nothing as such which can tell you the exact rate of completion, but you may simulate it taking the average of some attempts.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Are you changing the text using a seperate thread?
I did not understand what you mean excatly but here are sample codes.
con.ConnectionString = "Driver={Client Access ODBC Driver (32-bit)};System=xxxx;Uid=xxxxx;Pwd=xxxxxxx";
try
{
con.Open();
cmd = new OdbcCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
lblStatus.Text = "Starting Select Process";
cmd.CommandText = "Select Article, Store, Month, Year, Day, SUM(UD) AS UNIT, " +
"SUM(Value) AS VALUE from Data" +
" Where Year="+txtYil.Text+" AND Month= "+txtAy.Text+" AND Day BETWEEN "+
txtBaslangic.Text+" AND "+txtBitis.Text+
"GROUP BY Article, Store, Month, Year, Day";
cmd.CommandTimeout = 0;
lblStatus.Text = "Data is being selected";
dr = cmd.ExecuteReader();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
lblStatus.Text = "Data is being inserted to Access";
oleCon = u.oleCon("NXAC"+txtYil.Text+txtAy.Text+".mdb");
oleCon.Open();
while (dr.Read())
{
if (olecmd != null)
{
olecmd.Dispose();
}
olecmd = new OleDbCommand();
olecmd.Connection = oleCon;
olecmd.CommandType = CommandType.Text;
|
|
|
|
|
try calling...
this.Refresh();
after each text update, this is a quick fix.
I would suggest you look into the BackgroundWorker component for a better solution
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
I went for Background worker, it is a great solution.
Thanks alot.
|
|
|
|
|
I want to send Email in Arabic ;
I have used genaral SmtpMail class to send email,.. but when i send Arabic text email it shows like '?????????' for the all text;
i did objMsg.BodyFormat = MailFormat.Html; also but no Luck.
There are many ActiveX,.Component available,..
But i want to know in using .Net class same SMTP;
If any body know plz tell me;
Your corperation is appreciated!
B/rgs
Anushka
|
|
|
|
|
try using
mailMessage.BodyEncoding = Encoding.Unicode;
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
I've used
theMessage.BodyEncoding = Encoding.UTF8;<br />
Is using Encoding.Unicode better for Arabic than Encoding.UTF8 ?
Regards,
Gary
|
|
|
|
|
Hi
I'm trying to add a web reference to my windows app, but .net is not allowing this, i'm getting the following error Operation is not valid due to the current state of the object., i understand that this has to do with proxy, how do i solve his problem, my browser opens the web service without a problem
thanx in advance
|
|
|
|
|
try this in your application's web config/ app config and add the following under the <configuration> element:
<system.net>
<defaultProxy>
<proxy usesystemdefault="True" proxyaddress=http:
</defaultProxy>
</system.net>
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
i tried that it doesn't seem to be working.
|
|
|
|
|
Google and I were not friends today, so I ask you guys here!
This project has GridView control and MenuStrip which is set in grid's ContextMenuStrip to pop up when user is pressing right mouse button over the grid.
When user is pressing right mouse button over GridView the current row is not automatically set to the row "under" mouse pointer.
How is it possible to change current row (focus on) to the row under mouse pointer at that point before toolstrip menu is shown?
|
|
|
|
|
Raybarg wrote: How is it possible to change current row (focus on) to the row under mouse pointer at that point before toolstrip menu is shown?
It may not be. Without looking at the Grid documentation I would guess, like other controls, you can determine the row based on the mouse pointer coordinates.
Keep in mind this is a complete guess on my part and if I am wrong someone else will likely reply to you with the correct solution.
|
|
|
|
|
In the cell mouse down event open your context menu rather than using the built in context menu property.
|
|
|
|
|
The row is selected on the left mouse down.
while in your case, you do a right mouse click to show the menu strip.
You can instead fake this in the OnCellMouseClickEvent
if (e.Button == MouseButtons.Right)
{
if(this.datagridview1.SelectedRows.Count > 0)
this.datagridview1.SelectedRows[0].Selected = false;
this.datagridview1.Rows[e.RowIndex].Selected = true;
}
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Yes, that works with the solution Ennis suggested to pop the menu after doing that.
And here is how I got the menu positioned correctly:
Point pt = MyGrid.PointToClient(Control.MousePosition);
MyMenuStrip.Show(MyGrid, pt.X, pt.Y);
Thank you all for helping in this simple matter.
|
|
|
|
|
Hi again!
Since I had CurrencyManager in BindingContext, your suggested solution resulted in CurrencyManager position not changing when user right-clicked the grid so I had to google again, this time with more words in the issue to succeed.
Here's the solution:
Using DataGridViewCellMouseEventArgs e I can change current row by setting CurrentCell property:
this.datagridview1.CurrentCell = this.datagridview1[e.ColumnIndex, e.RowIndex];
And I repaste the code submitted in other post which pops the context menu also:
Point pt = datagridview1.PointToClient(Control.MousePosition);
menustrip1.Show(datagridview1, pt.X, pt.Y);
Thanks for your help again, the grid is working exactly like I want it to now!
|
|
|
|