Click here to Skip to main content
15,895,084 members
Home / Discussions / C#
   

C#

 
GeneralRe: LibUsbDotNet read write USB Port Pin
mihai12321-Apr-08 1:45
mihai12321-Apr-08 1:45 
Generalwrite xml root element attribute string in .net(C#) Pin
r aa j20-Apr-08 23:14
r aa j20-Apr-08 23:14 
GeneralRe: write xml root element attribute string in .net(C#) Pin
Christian Graus20-Apr-08 23:31
protectorChristian Graus20-Apr-08 23:31 
GeneralProblem in Creating Widget Pin
rakesh_csit20-Apr-08 23:06
rakesh_csit20-Apr-08 23:06 
GeneralRe: Problem in Creating Widget Pin
Christian Graus20-Apr-08 23:31
protectorChristian Graus20-Apr-08 23:31 
GeneralSelectively show custom controls on the toolbox bar in VS2005 Pin
Rey999920-Apr-08 22:55
Rey999920-Apr-08 22:55 
AnswerRe: Selectively show custom controls on the toolbox bar in VS2005 Pin
Rey999920-Apr-08 23:37
Rey999920-Apr-08 23:37 
Generalbase64Binary Pin
JustRonald20-Apr-08 22:46
JustRonald20-Apr-08 22:46 
GeneralRe: base64Binary Pin
Mustafa Ismail Mustafa21-Apr-08 0:09
Mustafa Ismail Mustafa21-Apr-08 0:09 
GeneralRe: base64Binary Pin
JustRonald21-Apr-08 1:43
JustRonald21-Apr-08 1:43 
QuestionHow to get the Runnning instance of Netscape navigator [modified] Pin
renilraj20-Apr-08 21:44
renilraj20-Apr-08 21:44 
GeneralRe: How to get the Runnning instance of Netscape navigator Pin
leppie21-Apr-08 4:18
leppie21-Apr-08 4:18 
Generalproblem run exe file Pin
chf120-Apr-08 21:38
chf120-Apr-08 21:38 
GeneralRe: problem run exe file Pin
Steve Echols20-Apr-08 21:52
Steve Echols20-Apr-08 21:52 
GeneralON exporting a structure inside a dll Pin
Member 475670920-Apr-08 21:18
Member 475670920-Apr-08 21:18 
GeneralRe: ON exporting a structure inside a dll Pin
Christian Graus20-Apr-08 22:08
protectorChristian Graus20-Apr-08 22:08 
GeneralInvalid postback or callback argument Pin
dabuskol20-Apr-08 21:04
dabuskol20-Apr-08 21:04 
GeneralRe: Invalid postback or callback argument Pin
Christian Graus20-Apr-08 22:12
protectorChristian Graus20-Apr-08 22:12 
Questionhow to skip a word document using c#.net Pin
Nitin Raj20-Apr-08 21:02
Nitin Raj20-Apr-08 21:02 
AnswerRe: how to skip a word document using c#.net Pin
Steve Echols20-Apr-08 21:55
Steve Echols20-Apr-08 21:55 
Generalkeyboard hook Pin
Razvan Dimescu20-Apr-08 20:58
Razvan Dimescu20-Apr-08 20:58 
I added a keyboard hook by calling the SetWindowsHookEx but the delegate I was passing as a parameter for the function was being garbage collected, although the delegate was declared as a global variable. I was instantiating the delegate in a method, but, after instantiating it in the constructor of the class that contained the delegate it stopped being garbage collected and the problem was solved.

While doing some research I found Chris Brumme's blog were he Is saying that it's a better practice use a delegate and call the native method asynchronously rather than pinning the delegate that was GC in the memory. Therefore I tried this approach
public delegate IntPtr SetHookDelegate(int idHook, HookProc lpfn, IntPtr hInstance, uint threadId);
      SetHookDelegate myookDelegate = null;

using (Process curProcess = Process.GetCurrentProcess())
            using (ProcessModule curModule = curProcess.MainModule)
            {
                myookDelegate = new SetHookDelegate(Win32.SetWindowsHookEx);
                myookDelegate.BeginInvoke((int)Win32.HookType.WH_KEYBOARD_LL,
                HookProcedure,
                Win32.GetModuleHandle(curModule.ModuleName),
                0, new AsyncCallback(CallMeWhenFinished), myReturnValue);
            }

but the callback method "CallMeWhenFinished" is called right away and the thread on which the hook was added is finished without waiting for the delegate passed as a parameter to the native function SetWindowsHookEx. Why is the thread finished right away and not listening on the callback function?


GeneralRe: keyboard hook Pin
leppie21-Apr-08 4:17
leppie21-Apr-08 4:17 
GeneralRe: keyboard hook Pin
Razvan Dimescu21-Apr-08 4:26
Razvan Dimescu21-Apr-08 4:26 
Generalaccess an application existing on a server Pin
michael_jhons20-Apr-08 20:46
michael_jhons20-Apr-08 20:46 
GeneralRe: access an application existing on a server Pin
Christian Graus20-Apr-08 22:09
protectorChristian Graus20-Apr-08 22:09 

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.