Click here to Skip to main content
15,868,141 members
Home / Discussions / C#
   

C#

 
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 
GeneralRe: access an application existing on a server Pin
michael_jhons21-Apr-08 20:43
michael_jhons21-Apr-08 20:43 
GeneralMarshaling structure. Exception rises. Pin
bitwise20-Apr-08 20:38
bitwise20-Apr-08 20:38 
GeneralRe: Marshaling structure. Exception rises. Pin
leppie21-Apr-08 4:29
leppie21-Apr-08 4:29 
GeneralRename Excel sheets after exporting to a new Excel spreadsheet Pin
Walaza20-Apr-08 20:21
Walaza20-Apr-08 20:21 
GeneralRe: Rename Excel sheets after exporting to a new Excel spreadsheet Pin
moon_stick21-Apr-08 1:36
moon_stick21-Apr-08 1:36 
GeneralRe: Rename Excel sheets after exporting to a new Excel spreadsheet [modified] Pin
Walaza21-Apr-08 3:28
Walaza21-Apr-08 3:28 
GeneralReading selected items of one listbox to other list box using javascript Pin
csp20-Apr-08 19:45
csp20-Apr-08 19:45 
GeneralRe: Reading selected items of one listbox to other list box using javascript Pin
Christian Graus20-Apr-08 19:53
protectorChristian Graus20-Apr-08 19:53 
GeneralOn calling a function written in c from a dotnet c# application Pin
Member 475670920-Apr-08 19:28
Member 475670920-Apr-08 19:28 
GeneralRe: On calling a function written in c from a dotnet c# application Pin
Christian Graus20-Apr-08 19:54
protectorChristian Graus20-Apr-08 19:54 
GeneralRe: On calling a function written in c from a dotnet c# application Pin
Member 475670920-Apr-08 20:54
Member 475670920-Apr-08 20:54 
GeneralUser permissions to a DCOM object Pin
random420-Apr-08 19:15
random420-Apr-08 19:15 
GeneralRe: User permissions to a DCOM object Pin
Nouman Bhatti20-Apr-08 19:58
Nouman Bhatti20-Apr-08 19:58 

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.