Hi all, I have a simple serial port application in which I am listening to serial port and displaying all the data which is received to a richtextbox. My Question is; When i build the application and run in "Debug" configuration I get "The I/O operation has been aborted because of either a thread exit or an application request
" exception at serialPort.ReadExisting()
transaction. However when I build the application in "Release" Configuration I never see this exception. In my opinion there is no reason for the exception, but unfortunately I get it in debug mode. Any ideas? Kind Regards zafer
zafersavas
Posts
-
Debug vs. Release -
Serial Port Strange Error!Hello everyone, I am trying to send an array of bytes using the serial port and I get a strange I/O exception. In my opinion there is no reason for the error. Here is the code;
SerialPort comport = new SerialPort("COM1", 57600, Parity.None, 8, StopBits.One);
comport.Open();byte[] data = new byte[16];
comport.Write(data, 0, 16); // This func gives the ExceptionThe details for the exception is "The I/O operation has been aborted because of either a thread exit or an application request". How and why a
write
function can give an exception? Any ideas will be appreciated :) zafer -
help in tab controlHave a look at this:
private void Form1\_Load(object sender, EventArgs e) { TabControl tabControl1 = new TabControl(); TabPage tabPage1 = new TabPage(); TabPage tabPage2 = new TabPage(); TabPage tabPage3 = new TabPage(); TabPage tabPage4 = new TabPage(); TabPage tabPage5 = new TabPage(); Label label1 = new Label(); // Allows multiple rows of tabs in the tabControl1 tab strip. tabControl1.Multiline = true; tabControl1.SizeMode = TabSizeMode.FillToRight; tabControl1.Padding = new Point(15, 5); tabControl1.Controls.AddRange(new Control\[\] { tabPage1, tabPage2, tabPage3, tabPage4, tabPage5}); tabControl1.Location = new Point(35, 65); tabControl1.Size = new Size(220, 180); // Gets the number of rows currently in the tabControl1 tab strip. // Assigns int value to the rows variable. int rows = tabControl1.RowCount; label1.Text = "There are " + rows.ToString() + " rows of tabs in the tabControl1 tab strip."; label1.Location = new Point(35, 25); label1.Size = new Size(220, 30); Size = new Size(300, 300); Controls.AddRange(new Control\[\] { label1, tabControl1 }); }
zafer
-
Access RS-232 in C# using VISAAgilent visa comes with great examples. My advice to you is to install agilent io libraries (http://www.home.agilent.com/agilent/product.jspx?pn=E2094R[^]) and to have a look at the examples/documentation. Good luck zafer
-
UdpClient Error : Only one usage of each socket address (protocol/network address/port) is normally permittedHello everyone, I am having trouble with UdpClient class. Here is my code:
private UdpClient myClient;
private void button1_Click(object sender, EventArgs e)
{
myClient = new UdpClient(7777);
}private void button2\_Click(object sender, EventArgs e) { myClient.Close(); }
So when I press button1 to connect for the first time - Everything is OK when I press button2 to discconect - Everything is OK But when I try to connect for the second time by pressnig button1 I get the error :
"Only one usage of each socket address (protocol/network address/port) is normally permitted"
How can I solve this problem? How can I bind my socket again? Any help will be appreciated. Regards -
how to know by coding between two computer ?If they have "Network interface cards" then you can check their MAC addresses, because MAC address is unique.
-
forms or usercontrols or panels or what ?I really did not understand what you mean by "Module" and "mask".:confused: You said that you are new in C#, I have been written C# for about 5 years and I have never used these words. LOL :-D
-
Converting CString to char*Hi super_ttd, What's the problem with CString::GetBuffer()? Why dont you like it? :)
-
Converting CString to char*There a various ways: 1)
CString str = "filename";
char charPtr[100];
sprintf(charPtr, "%s", str);CString str = "filename";
char* charPtr = str.GetBuffer(str.GetLength()); -
Get ControlsYou can use something like this:
foreach (Form frm in Application.OpenForms)
{
foreach (Control ctrl in frm.Controls)
MessageBox.Show(ctrl.Text);
}This contains two foreach statement but indepedent of how many forms you have, you can get their controls. zafer
-
IOExpection error using Streamreader and FileStreamI think the reason for the answer is obvious : "c:\\measurement.log" is being used by another program. Instead of reading the log file and displaying the results, you should directly get data from the usb device.
yefeng_law wrote:
I also try another method which is directly from the usb port which the device is connected to but i am unable to start working on it coding
Why? have a look at the examples and if still can not solve contact the manufacturer of the device for library. Thats the only way I think.
-
can someone help me in this program..You should know that people in this forum are bored of these kinds of questions. And answer to your question : Hire a programmer.
-
creating real time graphical line chartYou should have a library to communicate with your measurement instrument. Probably you can download it from the manufacturers web-site. How to display the measurements on a graphical display? ZedGraph : http://www.codeproject.com/KB/graphics/zedgraph.aspx[^] Don't bother with other plotting libraries, ZedGraph is the best. Good luck zafer
-
[Message Deleted]Well, this topic seems going deeper :)
DaveyM69 wrote:
what if you have multiple objects that need to know that form2 is closing? You'd need to pass every object in the constructor. How can you predetermine how many there will be or what types?
absolutely no, no and no, have a look at this:
Form1 : is the main form, Form2 and Form3 are declared here. Form2(Form1 frmRef); Form3(Form1 frmRef);
2 knows 1, 1 knows 3 so 2 can know 3 through 1. Just pass Form1 as a constructor parameter and dont think the rest. As every form is aware of Form1 and Form1 is where other forms are declared, this means "everybody knows everybody". Form1 is something like a common node for all others. So as you see you dont have to pass other forms to the constructor. Anyway, its a way up to you. No problem if it is efficient and causing any trouble. Kind regards zafer -
[Message Deleted]Sorry I disagree, what do you mean by "not good"? Are you aware that in form1 code you are writing code related with form2. What if you have form3, form4 etc. Than your form1 gets larger and larger. Passing the reference of the main form to other forms is a practical way of form communication.
-
[Message Deleted]The answers above are all quite helpful and here is the source code to help you: In
Form1
:private void myButton_Click(object sender, EventArgs e)
{
changeMyButton(false);
Form2 frm2 = new Form2(this);
frm2.Show();
}
public void changeMyButton(bool state)
{
myButton.Enabled = state;
}In
Form2
:Form1 form1Ref;
public Form2(Form1 fRef)
{
InitializeComponent();
form1Ref = fRef;
}
private void Form2_FormClosing(object sender, FormClosingEventArgs e)
{
form1Ref.changeMyButton(true);
}Good luck zafer
-
how can i draw a rectangle from a separate antoher winForm?Your problem is not with the drawing part, you want to pass data from one form to another form I think. i.e: You want to know that a rectangle was selected in the
first form
and draw a rectangle in thesecond form
. So the easiest way to exchange data between forms is to pass the reference of one form to the other form that is:// Pass the reference of Form1 to the Form2 during Form2 construction:
Form1 form1Ref;
public Form2(Form1 fRef)
{
InitializeComponent();
form1Ref = fRef;
}After this you can reach the public member variables/function of form1 from form2. So if you keep the info of selected settings in a variable in form1 you can get them from form2. PS: I recognized that unnecessary white spaces and unindented codes really disturb me. Why don't you tidy your code :) Good luck zafer
-
Set the light/siren device on in C#First of all, You said:
I have a light/siren device that is plugged into my computer.
How is it connected to the computer? Is it RS-232, Parallel Port, USB etc... You should know the interface between your equipment and the PC. - If it is RS-232, probably there are serial commands which makes the the light ON/OFF. .NET framework includes serial port libraries so you can easily send and receive commands. - If it is parallel port, you should set/reset necessary bits to make light ON/OFF. There is a popular, free library for parallel port :inpout32.dll
- If it is something else, you should be given some library to control the light. You should just call it from your application. Good luck zafer -
Sharing a lesson...Exactly, because arrays in C# are reference types.
-
login dialog helpYes quite acceptable. Most people probably will do that way. Good luck.