Calling console application periodically

ALEXNG2012

New member
Joined
Jan 1, 2012
Messages
2
Programming Experience
5-10
HI,
I have a USB device and with SDK inside. However, the sample code are in console, is it possible for me to create a windows form to call the console application periodically?? What is the best way to do so since I need to run virtually infinitely.

Thanks
Alex
 
The samples are just samples. You're supposed to use them to gain an understanding of how to use the component and then write your own code in your own application to use it in an appropriate way.

Most likely the SDK provides an unmanaged, i.e. non-.NET, DLL. In that case you must use pinvoke, just like for Windows API functions. You need to write a function in your .NET code with a compatible signature and then apply the DllImport attribute. You can then call that function and it will invoke the original function in the unmanaged DLL.
 
Hi,
Thanks! The code looks like:
<MTAThread()> _
Sub Main()

Dim lw As ListenerWindow = New ListenerWindow
Dim msg_str_of_find As String = "find"
Dim msg_str_of_enable As String = "enable"
Dim bRet As Boolean = False
Dim i As Integer
Dim card_find_message As UInt32 = RegisterWindowMessage(msg_str_of_find)


If (card_find_message.Equals(Convert.ToUInt32(0))) Then
Console.Write("Failed: RegisterWindowMessage")
Environment.ExitCode = EXIT_FAILED
Return
End If

Dim card_enable_message As UInt32 = RegisterWindowMessage(msg_str_of_enable)
If (card_enable_message.Equals(Convert.ToUInt32(0))) Then
Console.Write("Failed: RegisterWindowMessage")
Environment.ExitCode = EXIT_FAILED
Return
End If
For i = 0 To 20
System.Threading.Thread.Sleep(1000)
bRet = lw.WatchMessage(card_find_message)
If (bRet = False) Then
Console.WriteLine("Failed: WatchMessage")
Environment.ExitCode = EXIT_FAILED
Return
End If

lw.WatchMessage(card_enable_message)
If (bRet = False) Then
Console.WriteLine("Failed: WatchMessage")
Environment.ExitCode = EXIT_FAILED
Return
End If
....

so you mean I need to re-write the code and compile it into DLL?

pls advise
 
Back
Top