Click here to Skip to main content
15,885,365 members
Home / Discussions / C#
   

C#

 
GeneralRe: Looking for a WCF host Pin
L Viljoen28-Mar-12 19:17
professionalL Viljoen28-Mar-12 19:17 
GeneralRe: Looking for a WCF host Pin
jschell29-Mar-12 7:58
jschell29-Mar-12 7:58 
Questionpassing array of doubles Pin
__John_28-Mar-12 2:57
__John_28-Mar-12 2:57 
AnswerRe: passing array of doubles Pin
BobJanova28-Mar-12 5:52
BobJanova28-Mar-12 5:52 
AnswerRe: passing array of doubles Pin
kevinnicol28-Mar-12 7:01
kevinnicol28-Mar-12 7:01 
GeneralRe: passing array of doubles Pin
BobJanova28-Mar-12 22:44
BobJanova28-Mar-12 22:44 
AnswerRe: passing array of doubles Pin
__John_28-Mar-12 23:06
__John_28-Mar-12 23:06 
GeneralRe: passing array of doubles Pin
DaveyM6929-Mar-12 2:46
professionalDaveyM6929-Mar-12 2:46 
I've found sometimes the only way to reliably do stuff like this is to use System.Runtime.InteropServices.GCHandles.
C#
double[] pdXVals = new double[] { 1, 2, 3 };
double[] pdYVals = new double[] { 4, 5, 6 };
GCHandle handleX = GCHandle.Alloc(pdXVals, GCHandleType.Pinned);
GCHandle handleY = GCHandle.Alloc(pdYVals, GCHandleType.Pinned);
// change your wrapper function to GCHandle pdXVals, GCHandle pdYVals
// and pass handleX, handleY

// alternatively, the function can take an IntPtr and you can pass handleX.AddrOfPinnedObject() etc
            
// Important! after function call, when done with the handles
handleX.Free();
handleY.Free();

I'm assuming there is a fixed size for the arrays? If not, as there is no size parameter there is no way for the function to know when to stop reading memory and you will get garbage data and/or exceptions.
Dave

Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.
Astonish us. Be exceptional. (Pete O'Hanlon)

BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)



AnswerRe: passing array of doubles Pin
Henry Minute29-Mar-12 4:38
Henry Minute29-Mar-12 4:38 
Questionruntime change into database Pin
Member 823360127-Mar-12 19:57
Member 823360127-Mar-12 19:57 
AnswerRe: runtime change into database Pin
Richard MacCutchan27-Mar-12 22:25
mveRichard MacCutchan27-Mar-12 22:25 
AnswerRe: runtime change into database Pin
Eddy Vluggen28-Mar-12 7:14
professionalEddy Vluggen28-Mar-12 7:14 
GeneralRe: runtime change into database Pin
Member 823360129-Mar-12 19:12
Member 823360129-Mar-12 19:12 
QuestionHow to make 64-bit registry writable in 32-bit application Pin
gshen27-Mar-12 13:55
gshen27-Mar-12 13:55 
AnswerRe: How to make 64-bit registry writable in 32-bit application Pin
Richard Andrew x6427-Mar-12 14:44
professionalRichard Andrew x6427-Mar-12 14:44 
GeneralRe: How to make 64-bit registry writable in 32-bit application Pin
gshen28-Mar-12 14:02
gshen28-Mar-12 14:02 
QuestionCopying/replacing a file in the system dir? Pin
Muammar©27-Mar-12 1:23
Muammar©27-Mar-12 1:23 
AnswerRe: Copying/replacing a file in the system dir? PinPopular
Pete O'Hanlon27-Mar-12 1:35
mvePete O'Hanlon27-Mar-12 1:35 
GeneralRe: Copying/replacing a file in the system dir? Pin
Vipin_Arora27-Mar-12 2:56
Vipin_Arora27-Mar-12 2:56 
AnswerRe: Copying/replacing a file in the system dir? Pin
Vipin_Arora27-Mar-12 2:58
Vipin_Arora27-Mar-12 2:58 
AnswerRe: Copying/replacing a file in the system dir? Pin
Eddy Vluggen27-Mar-12 5:17
professionalEddy Vluggen27-Mar-12 5:17 
QuestionBypass Windows Message other than Open & Close Pin
varunpandeyengg26-Mar-12 22:25
varunpandeyengg26-Mar-12 22:25 
AnswerRe: Bypass Windows Message other than Open & Close Pin
Mycroft Holmes26-Mar-12 22:29
professionalMycroft Holmes26-Mar-12 22:29 
GeneralRe: Bypass Windows Message other than Open & Close Pin
varunpandeyengg26-Mar-12 22:46
varunpandeyengg26-Mar-12 22:46 
GeneralRe: Bypass Windows Message other than Open & Close Pin
N a v a n e e t h27-Mar-12 1:20
N a v a n e e t h27-Mar-12 1:20 

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.