Click here to Skip to main content
15,902,112 members
Home / Discussions / C#
   

C#

 
QuestionDIfference between Q/A and Discussion? Pin
agent_kruger16-Jan-14 1:43
professionalagent_kruger16-Jan-14 1:43 
AnswerRe: DIfference between Q/A and Discussion? Pin
Richard MacCutchan16-Jan-14 2:10
mveRichard MacCutchan16-Jan-14 2:10 
AnswerRe: DIfference between Q/A and Discussion? PinPopular
BillWoodruff16-Jan-14 6:02
professionalBillWoodruff16-Jan-14 6:02 
GeneralRe: DIfference between Q/A and Discussion? Pin
agent_kruger16-Jan-14 23:38
professionalagent_kruger16-Jan-14 23:38 
GeneralRe: DIfference between Q/A and Discussion? Pin
Pete O'Hanlon16-Jan-14 23:55
mvePete O'Hanlon16-Jan-14 23:55 
QuestionHow to use SQL store procedure in LINQ in C#? Pin
Brijesh Kumar Prajapati16-Jan-14 0:09
Brijesh Kumar Prajapati16-Jan-14 0:09 
AnswerRe: How to use SQL store procedure in LINQ in C#? Pin
Eddy Vluggen16-Jan-14 0:17
professionalEddy Vluggen16-Jan-14 0:17 
QuestionApplication requires Microsoft.Vbe.Interop Ver .... installed in GAC Pin
emma.sun.sts15-Jan-14 22:35
emma.sun.sts15-Jan-14 22:35 
AnswerRe: Application requires Microsoft.Vbe.Interop Ver .... installed in GAC Pin
Wayne Gaylard15-Jan-14 23:05
professionalWayne Gaylard15-Jan-14 23:05 
GeneralRe: Application requires Microsoft.Vbe.Interop Ver .... installed in GAC Pin
emma.sun.sts16-Jan-14 23:10
emma.sun.sts16-Jan-14 23:10 
AnswerRe: Application requires Microsoft.Vbe.Interop Ver .... installed in GAC Pin
Freak3016-Jan-14 2:17
Freak3016-Jan-14 2:17 
GeneralRe: Application requires Microsoft.Vbe.Interop Ver .... installed in GAC Pin
emma.sun.sts16-Jan-14 23:05
emma.sun.sts16-Jan-14 23:05 
AnswerRe: Application requires Microsoft.Vbe.Interop Ver .... installed in GAC Pin
jschell16-Jan-14 8:33
jschell16-Jan-14 8:33 
GeneralRe: Application requires Microsoft.Vbe.Interop Ver .... installed in GAC Pin
emma.sun.sts16-Jan-14 23:03
emma.sun.sts16-Jan-14 23:03 
GeneralRe: Application requires Microsoft.Vbe.Interop Ver .... installed in GAC Pin
jschell17-Jan-14 12:59
jschell17-Jan-14 12:59 
Questionhow to Create video Conference Application Pin
Member 1052727315-Jan-14 21:41
professionalMember 1052727315-Jan-14 21:41 
AnswerRe: video recording Pin
Richard MacCutchan15-Jan-14 21:48
mveRichard MacCutchan15-Jan-14 21:48 
Questionrepeater in c# Pin
ptvce15-Jan-14 20:40
ptvce15-Jan-14 20:40 
AnswerRe: repeater in c# Pin
Simon_Whale15-Jan-14 22:12
Simon_Whale15-Jan-14 22:12 
QuestionPerform exact function in timer tick after a specific time Pin
CodingHell15-Jan-14 20:33
CodingHell15-Jan-14 20:33 
AnswerRe: Perform exact function in timer tick after a specific time Pin
Bernhard Hiller15-Jan-14 21:07
Bernhard Hiller15-Jan-14 21:07 
AnswerRe: Perform exact function in timer tick after a specific time Pin
BillWoodruff15-Jan-14 22:12
professionalBillWoodruff15-Jan-14 22:12 
Do you really mean 250 seconds ? My guess is: you mean milliseconds.

Why don't you set a boolean flag in the comport.DataReceived EventHandler, and use a 'while loop in your code after each send ? Here's a very rough sketch [1]:
C#
//required to use Stopwatch
using System.Diagnostics;

// inside Form Class scope
private bool hasResponded = false;

private Stopwatch theStopWatch;

// Stopwatch delay in milliseconds #1
private int waitHowLong1 = 250;

// Stopwatch delay in milliseconds #2
private int waitHowLong2 = 3000;

// original code missing parameter Type ! 
private void SerialDataReceivedEventHandler(dynamic port_DataReceived)
{
   // whatever ... use try/catch ?

   hasResponded = true;
}

private void senddata1(String str)
{
    // Convert the user's string of hex digits (ex: B4 CA E2) to a byte array
    //byte[] data = HexStringToByteArray(str);
    
    hasResponded = false;
    
    // Send the binary data out the port
    //comport.Write(data, 0, data.Length);
    
    // create and start a new Stopwatch
    theStopWatch = Stopwatch.StartNew();
    
    // delay 250 milliseconds
    while(true)
    {
        if (theStopWatch.ElapsedMilliseconds >= waitHowLong1) break;
    }
    
    Console.WriteLine("250 ms. wait done");
    
    theStopWatch.Stop();
    
    theStopWatch.Reset();
    
    theStopWatch.Start();
    
    // how long should you wait before you decide the update has failed ?
    while (true)
    {
        if (theStopWatch.ElapsedMilliseconds >= waitHowLong2) break;
    }
    
    theStopWatch.Stop();
    
    Console.WriteLine("3000 ms. wait done");
    
    if (! hasResponded) Console.WriteLine("failed to handle update");
}
[1] Note: the above is untested code: it will compile as shown here (certain lines commented out, and missing parameter Type for SerialDataReceivedEventHandler "fudged"), but there's no guarantee beyond that; use this code as a source of ideas only.

[2] examples of using System.Diagnostic.Stopwatch: [^]

[3] Note: if you are working with .NET 4.5, and Windows 8, by all means use the new Task.Delay method with Wait argument in System.Threading.Tasks: [^].
“But I don't want to go among mad people,” Alice remarked.

“Oh, you can't help that,” said the Cat: “we're all mad here. I'm mad. You're mad.”

“How do you know I'm mad?” said Alice.

“You must be," said the Cat, or you wouldn't have come here.” Lewis Carroll

Question@Utility.ConvertToDateTime Pin
JunjieC15-Jan-14 18:00
JunjieC15-Jan-14 18:00 
AnswerRe: @Utility.ConvertToDateTime Pin
Mycroft Holmes15-Jan-14 18:32
professionalMycroft Holmes15-Jan-14 18:32 
AnswerRe: @Utility.ConvertToDateTime Pin
Jameel VM15-Jan-14 18:43
Jameel VM15-Jan-14 18:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.