Click here to Skip to main content
15,887,214 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to pin List to unmanaged byte** Pin
Chesnokov Yuriy19-Jan-11 19:02
professionalChesnokov Yuriy19-Jan-11 19:02 
GeneralRe: How to pin List to unmanaged byte** Pin
_Erik_19-Jan-11 3:06
_Erik_19-Jan-11 3:06 
GeneralRe: How to pin List to unmanaged byte** Pin
Chesnokov Yuriy19-Jan-11 4:18
professionalChesnokov Yuriy19-Jan-11 4:18 
GeneralRe: How to pin List to unmanaged byte** Pin
_Erik_19-Jan-11 5:10
_Erik_19-Jan-11 5:10 
AnswerRe: How to pin List to unmanaged byte** Pin
Chesnokov Yuriy19-Jan-11 9:45
professionalChesnokov Yuriy19-Jan-11 9:45 
GeneralRe: How to pin List to unmanaged byte** [modified] Pin
_Erik_19-Jan-11 10:55
_Erik_19-Jan-11 10:55 
AnswerRe: How to pin List to unmanaged byte** Pin
Chesnokov Yuriy19-Jan-11 19:12
professionalChesnokov Yuriy19-Jan-11 19:12 
GeneralRe: How to pin List to unmanaged byte** Pin
_Erik_20-Jan-11 2:37
_Erik_20-Jan-11 2:37 
Yes, GCHandle is a pretty delicate thing. When a GCHandle is created it adds a new entry to the AppDomain's handle table, and this entry is kept there until Free method is invoked. The problems may arise when we create more GCHandle objects to the same target and in the same method. Remember GCHandle is also a struc, I mean, a value type, so any instance of it will be a different copy into the stack. Even if you made this:

C#
GCHandle handle2 = handle1;


Since GCHandle is a struct, freeing handle2 would not free handle1, and this might take us to a strange situation becouse handle1's target might become a null reference, and this handle would still be in the AppDomain's handle table. This is the reason why I always try to avoid making several copies of a GCHandle.

Summarizing, it is much better to maintain the array of GCHandle objects than trying to recreate them.
AnswerRe: How to pin List to unmanaged byte** Pin
Chesnokov Yuriy19-Jan-11 4:27
professionalChesnokov Yuriy19-Jan-11 4:27 
AnswerRe: How to pin List<byte[]> to unmanaged byte** Pin
SledgeHammer0118-Jan-11 9:33
SledgeHammer0118-Jan-11 9:33 
AnswerRe: How to pin List to unmanaged byte** Pin
Chesnokov Yuriy18-Jan-11 19:08
professionalChesnokov Yuriy18-Jan-11 19:08 
GeneralRe: How to pin List to unmanaged byte** Pin
SledgeHammer0119-Jan-11 10:25
SledgeHammer0119-Jan-11 10:25 
AnswerRe: How to pin List to unmanaged byte** Pin
Chesnokov Yuriy19-Jan-11 19:03
professionalChesnokov Yuriy19-Jan-11 19:03 
GeneralRe: How to pin List to unmanaged byte** [modified] Pin
SledgeHammer0120-Jan-11 8:41
SledgeHammer0120-Jan-11 8:41 
QuestionOn Error Resume Next Pin
Anubhava Dimri17-Jan-11 18:24
Anubhava Dimri17-Jan-11 18:24 
AnswerRe: On Error Resume Next PinPopular
JF201517-Jan-11 18:31
JF201517-Jan-11 18:31 
GeneralRe: On Error Resume Next Pin
Anubhava Dimri17-Jan-11 19:09
Anubhava Dimri17-Jan-11 19:09 
GeneralRe: On Error Resume Next Pin
fjdiewornncalwe18-Jan-11 8:56
professionalfjdiewornncalwe18-Jan-11 8:56 
AnswerRe: On Error Resume Next Pin
Dave Kreskowiak17-Jan-11 18:59
mveDave Kreskowiak17-Jan-11 18:59 
AnswerRe: On Error Resume Next Pin
Abhinav S17-Jan-11 20:55
Abhinav S17-Jan-11 20:55 
AnswerRe: On Error Resume Next Pin
OriginalGriff17-Jan-11 21:20
mveOriginalGriff17-Jan-11 21:20 
GeneralRe: On Error Resume Next Pin
nlarson1118-Jan-11 3:43
nlarson1118-Jan-11 3:43 
GeneralRe: On Error Resume Next Pin
OriginalGriff18-Jan-11 4:00
mveOriginalGriff18-Jan-11 4:00 
GeneralRe: On Error Resume Next Pin
nlarson1118-Jan-11 4:16
nlarson1118-Jan-11 4:16 
GeneralRe: On Error Resume Next Pin
Matty2220-Jan-11 15:16
Matty2220-Jan-11 15:16 

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.