Click here to Skip to main content
15,886,788 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: physical address or MAC address Pin
Eddy Vluggen15-Mar-09 0:48
professionalEddy Vluggen15-Mar-09 0:48 
GeneralRe: physical address or MAC address Pin
0x3c015-Mar-09 4:36
0x3c015-Mar-09 4:36 
GeneralRe: physical address or MAC address Pin
Eddy Vluggen15-Mar-09 5:43
professionalEddy Vluggen15-Mar-09 5:43 
Question[Message Deleted] Pin
PleaseHelpCP14-Mar-09 20:28
PleaseHelpCP14-Mar-09 20:28 
AnswerRe: VB.net Pin
Expert Coming14-Mar-09 21:22
Expert Coming14-Mar-09 21:22 
GeneralRe: VB.net Pin
PleaseHelpCP14-Mar-09 22:30
PleaseHelpCP14-Mar-09 22:30 
AnswerRe: VB.net Pin
Christian Graus14-Mar-09 21:47
protectorChristian Graus14-Mar-09 21:47 
QuestionCallback function does not return to C++ Pin
Kurt Richardson14-Mar-09 6:33
Kurt Richardson14-Mar-09 6:33 
Hi All

I have a C++ DLL that performs some tasks and provides a regular update back to the VB.NET host so that a progress bar can be updated. The problem I have is that the callback fires once, but also exits the DLL for good.

Here is how my callback function is referenced in VB.NET

Imports System.Runtime.InteropServices

<UnmanagedFunctionPointer(CallingConvention.StdCall)> Public Delegate Sub controlProgressBarDelegate(ByVal progressValue As UInt32, ByVal message As String)

Public Declare Auto Sub CallBackTest Lib "CppTestDLL.dll" (ByRef arbitraryNum As Int32, ByVal pCallbackFunc As controlProgressBarDelegate)


The C++ DLL function "CallBackTest" is called via:

globalFuncsVars.CallBackTest(arbNumber, AddressOf controlProgressBar)


And the callback function, which simply updates a progress bar and puts any returned message string into a label, is:

Public Function controlProgressBar(ByVal progressValue As UInt32, ByVal message As String)

    ProgressBar1.Value = progressValue
    Label1.Text = message

    Return 0

End Function


Obviously this is a very simple test example.

The code in the C++ DLL is:

typedef void (__stdcall progressCallback)(int progress, const char * p_msg);

extern "C" __declspec(dllexport) int __stdcall CallBackTest(int arbitaryNumber, progressCallback * p_progressCallback)
{
	unsigned int counter = 0;
	const char msg[12] = "Counting...";

	for (unsigned int i = 0; i < 100; i += 1){
		p_progressCallback(counter, msg);
		counter += (i * 10);
		for(unsigned int j=0; i < 100000; i++){}
	}
	
	return 0;

}


Again, a simple example where the counter goes from 0 to 100 in steps of 1 (with intervals of 100000 clock cycles... ish).

Now, when p_progressCallback is first called the first value of counter = 0 and the contents of the msg string are indeed returned to the VB.NET controlProgressBar function. However, there it stops, after the controlProgressBar function is executed the thread does not return back to the DLL.

Any thoughts?

Apologies if this is more a C++ issue rather than a VB.NET issue.

Kind regards, Kurt
AnswerRe: Callback function does not return to C++ Pin
Kurt Richardson14-Mar-09 7:27
Kurt Richardson14-Mar-09 7:27 
AnswerRe: Callback function does not return to C++ Pin
Kurt Richardson14-Mar-09 17:18
Kurt Richardson14-Mar-09 17:18 
QuestionQuestion on DateTimePicker Pin
priyamtheone14-Mar-09 4:59
priyamtheone14-Mar-09 4:59 
AnswerRe: Question on DateTimePicker Pin
Christian Graus14-Mar-09 8:23
protectorChristian Graus14-Mar-09 8:23 
GeneralRe: Question on DateTimePicker Pin
Luc Pattyn14-Mar-09 9:13
sitebuilderLuc Pattyn14-Mar-09 9:13 
GeneralRe: Question on DateTimePicker Pin
Christian Graus14-Mar-09 9:32
protectorChristian Graus14-Mar-09 9:32 
GeneralRe: Question on DateTimePicker Pin
Luc Pattyn14-Mar-09 9:51
sitebuilderLuc Pattyn14-Mar-09 9:51 
GeneralRe: Question on DateTimePicker Pin
Christian Graus14-Mar-09 10:44
protectorChristian Graus14-Mar-09 10:44 
AnswerRe: Question on DateTimePicker Pin
Luc Pattyn14-Mar-09 9:51
sitebuilderLuc Pattyn14-Mar-09 9:51 
AnswerRe: Question on DateTimePicker Pin
priyamtheone16-Mar-09 7:05
priyamtheone16-Mar-09 7:05 
GeneralRe: Question on DateTimePicker Pin
Luc Pattyn16-Mar-09 7:11
sitebuilderLuc Pattyn16-Mar-09 7:11 
QuestionRe: Question on DateTimePicker Pin
priyamtheone17-Mar-09 6:09
priyamtheone17-Mar-09 6:09 
AnswerRe: Question on DateTimePicker Pin
Luc Pattyn17-Mar-09 6:40
sitebuilderLuc Pattyn17-Mar-09 6:40 
GeneralRe: Question on DateTimePicker Pin
priyamtheone19-Mar-09 5:26
priyamtheone19-Mar-09 5:26 
QuestionCustom control , custom properties Pin
udikantz14-Mar-09 0:06
udikantz14-Mar-09 0:06 
AnswerRe: Custom control , custom properties [modified] Pin
Eddy Vluggen15-Mar-09 1:54
professionalEddy Vluggen15-Mar-09 1:54 
QuestionArray Example Help Pin
StarTrekCafe13-Mar-09 16:40
StarTrekCafe13-Mar-09 16:40 

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.