|
I'm using the DataReceived event, which is processing the data once it's received a full packet. The main thread sends a packet and waits 400ms for a returned packet, which should be received with just a few ms turnaround. After waiting the timeout period it checks to see if any data has been received and processed. If the timeout is less than about 200ms then the processing doesn't start until after the timeout, 200-400 it's pot luck which happens first.
I hope you realise that hamsters are very creative when it comes to revenge. - Elaine
|
|
|
|
|
Hi,
1.
if the 400msec is from sending a command to getting a result, that would include:
- the output time; I would expect this simply is around N msec for N characters; it could be more on a USB-to-serial cable, as again data would be packetized probably based on a timeout;
- the reaction time; I don't know what your peripheral is, it needs to collect the command characters, interpret them, come up with an answer and send it; a tiny microcontroller (or poor software) might spend quite some time here; and if it is a meter of some kind, maybe it first has to perform its measurement, then report.
- only now can the PC start processing input. As I said earlier, that too would get packetized by the cable.
2.
if the main thread sends and waits, maybe it would be better to have it send and receive, without DataReceived event.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? 59.24% waren verstandig genoeg om NEEN te stemmen; bye bye viaduct.
|
|
|
|
|
Hello,
I work in console application, whene the timer was excuted, my console don't wait the end of timer, the console close direcly, how i can wait the end of timer ? thank you verry mutch.
|
|
|
|
|
Hi,
The problem will lie in the code you have written. I'll leave you to figure out what you need to do next.
Alan.
|
|
|
|
|
Hello
i do this :
public static System.Timers.Timer timer1;
private static void OnTimedEvent(object source, ElapsedEventArgs e)
{
Console.write("test");
}
static void Main(string[] args)
{
timer1 = new System.Timers.Timer();
timer1.Elapsed += new ElapsedEventHandler(OnTimedEvent);
timer1.Interval = 10000;
timer1.Start();
}
Unfortunatly, the console close witout excuting the timer, please help me, thak you verry mutch.
|
|
|
|
|
static void Main(string[] args)
{
timer1 = new System.Timers.Timer();
timer1.Elapsed += new ElapsedEventHandler(OnTimedEvent);
timer1.Interval = 10000;
timer1.Start();
Console.ReadLine()
}
|
|
|
|
|
If i put "Console.ReadLine()", the console don't close, i would close the console when the timer was stoped. thank you verry mutch.
|
|
|
|
|
Use a ManualResetEvent.
public static System.Timers.Timer timer1;
private static System.Threading.ManualResetEvent mrEvent = new System.Threading.ManualResetEvent(false);
private static void OnTimedEvent(object source, ElapsedEventArgs e)
{
Console.write("test");
mrEvent.Set();
}
static void Main(string[] args)
{
timer1 = new System.Timers.Timer();
timer1.Elapsed += new ElapsedEventHandler(OnTimedEvent);
timer1.Interval = 10000;
timer1.Start();
mrEvent.WaitOne();
}
|
|
|
|
|
Hi,
As written the main method will return and the application will terminate after the call to timer1.Start() . What is required is some form of wait and a simple and common way of doing this in console apps is to insert a call to Console.ReadLine()
timer1.Start();
Console.Readline();
Now the application will not terminate until the user presses the enter key.
Alan.
|
|
|
|
|
yes, we must to press enter key to exit environment, i would close the consol in end of timer, whene i excute timer.stop(); thank you.
|
|
|
|
|
WaitOne
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? 59.24% waren verstandig genoeg om NEEN te stemmen; bye bye viaduct.
|
|
|
|
|
I have it working if the mouse is used to click on the list box using the SelectedValueChanged event. However when someone uses the space bar or to checkmark or uncheckmark an item no envent is raised. How do I catch this change?
|
|
|
|
|
How about CheckChanged (like in CheckBox) ?
|
|
|
|
|
yepper that is what I found also.
|
|
|
|
|
im sorry, but i really need a help at my graduation project.......
How can i program the IP layer using socket programming on visuial C# at windows invironment??????
|
|
|
|
|
Do you want to program the IP layer, or do you want to send something over a socket[^]?
I are Troll
|
|
|
|
|
If you want to develop application using sockets in c# check out this[^] article.
Also Refer to this[^] if you want to understand what is socket.
Also Refer to System.net.sockets[^] class help.
|
|
|
|
|
Hi.
I am pretty new on C#, but since I have VB.NET background, I am not that lost.
I am looking to do two things.
1. I have records showing in text boxes that I bind from SQL Server 2005. I need to navigate through the records, showing the next record, till the last record. I need to use the "End of record" function.
2. I want to insert into the last column of my SQL Server 2005 database. But I need to find the last record on the table and increment the UserID(primary key) by one, and use the new value as the new UserID(primary key) on the new column.
Can you please help me with this.....
Thank you in advance guys.
|
|
|
|
|
Erhm... I see you're still talking about 'records'. This is a term used in VB. We got rid of records since VB.NET. Now we're talking about rows.
You cannot loop through a recordset and 'ask' the recordset if the EOF is reached. You have a 'table' which is your 'recordset' containing a collection of rows (tbl.Rows).
For example :
SELECT * FROM Users
The SQL statement loads all 'records' from the database table 'Users'.
Using C# :
using (DataTable tblUsers = new DataTable("Users"))
{
using (SqlConnection myConn = new SqlConnection(ConnectionString))
{
using (SqlDatAdapter adpUsers = new SqlDataAdapter("SELECT * FROM Users", myConn))
{
myConn.Open();
adpUsers.Fill(tblUsers);
myConn.Close();
}
}
foreach (DataRow drUserInformation in tblUsers.Rows)
{
}
}
|
|
|
|
|
Owkay, I have a feeling you are not understanding what I mean.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Connections
{
public partial class subForm : Form
{
public subForm()
{
InitializeComponent();
}
private void subForm_Load(object sender, EventArgs e)
{
buttonUpdate.Text = "Update";
string connectionString = @"Data Source=DBJNBWS0015\SQLEXPRESS;Initial Catalog=CarDealership;Integrated Security=True";
string sqlSel = @"Select * From Klient";
SqlConnection conndb = new SqlConnection(connectionString); //make a OleDbConnection object
DataSet ds = new DataSet(); //make a DataSet object
try
{
SqlDataAdapter myAdapter = new SqlDataAdapter(sqlSel, conndb); //Using the OleDbDataAdapter execute the query
myAdapter.Fill(ds, "Klient"); //Fill the DataSet with the Table 'Customers'
//dataGridView1.DataSource = ds.Tables["Klient"];
textBoxID.DataBindings.Add("Text", ds, "Klient.UserID");
textboxTitle.DataBindings.Add("Text", ds, "Klient.Title");
textBoxName.DataBindings.Add("Text", ds, "Klient.FirstName");
textBoxSurname.DataBindings.Add("Text", ds, "Klient.LastName");
textBoxLocation.DataBindings.Add("Text", ds, "Klient.City");
myAdapter.Dispose();
}
catch (Exception a)
{
MessageBox.Show("Error in connecting! " + e.ToString(), "Error");
}
finally
{
conndb.Close(); //Close the OleDbConnection
conndb.Dispose();
}
}
This simple code works. From this text boxes, I need to view the next row of data, and I have a button that inserts into a new row. before inserting, I need to make sure I am at the last row...In other words, I need to insert into a new row immediately after the last row.
|
|
|
|
|
Thank you guys...I have managed to read from the database.
Now the second trick is writing back to the database reading from the textboxes
|
|
|
|
|
i was complete my project the out put is send into Crystal Reports.but i need to send into PDF Fromate.how to do this program
adv thanks
lavan
|
|
|
|
|
You have to buy a PDF library, or find a free one that does what you want. I'm not sure how you'd integrate it with crystal reports.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
If I'm not mistaken pdf export can be done using the Crystal reports object model. You don't need additional software for that.
|
|
|
|
|
Depending on your version of crystal reports, crystal reports has an export to PDF method.
Dim crExportOptions As ExportOptions
Dim crDiskFileDestinationOptions As DiskFileDestinationOptions
Dim ExportPath As String = IO.Path.Combine(My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData, attachmentName & ".pdf")
' Set the path for the exported report
crDiskFileDestinationOptions = New DiskFileDestinationOptions
crDiskFileDestinationOptions.DiskFileName = ExportPath
' Set the options to export the report to PDF format
crExportOptions = rpt.ExportOptions
With crExportOptions
.DestinationOptions = crDiskFileDestinationOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
End With
' Export the report
rpt.Export()
with rpt being your crystal report.
(code is in vb.net but I'm sure you can convert that)
|
|
|
|