Click here to Skip to main content
15,888,454 members
Home / Discussions / C#
   

C#

 
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 
Questionsproxy.exe Web Service Proxy Generator download from where? Pin
Swab.Jat15-Jan-14 14:20
Swab.Jat15-Jan-14 14:20 
AnswerRe: sproxy.exe Web Service Proxy Generator download from where? Pin
Garth J Lancaster15-Jan-14 14:55
professionalGarth J Lancaster15-Jan-14 14:55 
AnswerRe: sproxy.exe Web Service Proxy Generator download from where? Pin
Dave Kreskowiak15-Jan-14 16:38
mveDave Kreskowiak15-Jan-14 16:38 
QuestionHOLA Pin
Giuliano Gonzales15-Jan-14 11:50
professionalGiuliano Gonzales15-Jan-14 11:50 
AnswerRe: HOLA Pin
Ron Beyer15-Jan-14 12:16
professionalRon Beyer15-Jan-14 12:16 
GeneralRe: HOLA Pin
Mycroft Holmes15-Jan-14 13:09
professionalMycroft Holmes15-Jan-14 13:09 
AnswerRe: HOLA Pin
Bernhard Hiller15-Jan-14 21:05
Bernhard Hiller15-Jan-14 21:05 
AnswerRe: HOLA Pin
Rahul VB31-Jan-14 23:16
professionalRahul VB31-Jan-14 23:16 
GeneralInterfacing Machines with LIS from Scratch Pin
max carter15-Jan-14 2:30
max carter15-Jan-14 2:30 
GeneralRe: Interfacing Machines with LIS from Scratch Pin
Pete O'Hanlon15-Jan-14 3:22
mvePete O'Hanlon15-Jan-14 3:22 
GeneralRe: Interfacing Machines with LIS from Scratch Pin
max carter15-Jan-14 3:25
max carter15-Jan-14 3:25 
GeneralRe: Interfacing Machines with LIS from Scratch Pin
Dave Kreskowiak15-Jan-14 3:33
mveDave Kreskowiak15-Jan-14 3:33 
GeneralRe: Interfacing Machines with LIS from Scratch Pin
max carter15-Jan-14 3:41
max carter15-Jan-14 3:41 
GeneralRe: Interfacing Machines with LIS from Scratch Pin
Pete O'Hanlon15-Jan-14 4:02
mvePete O'Hanlon15-Jan-14 4:02 

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.