Click here to Skip to main content
15,903,856 members
Home / Discussions / C#
   

C#

 
GeneralRe: Properties and User Ma... Pin
jas0n2329-Nov-08 5:14
jas0n2329-Nov-08 5:14 
Question[Message Deleted] Pin
jas0n2328-Nov-08 19:33
jas0n2328-Nov-08 19:33 
AnswerRe: URL Regular Expression f... Pin
AhsanS28-Nov-08 20:36
AhsanS28-Nov-08 20:36 
GeneralRe: URL Regular Expression f... Pin
jas0n2328-Nov-08 20:40
jas0n2328-Nov-08 20:40 
AnswerRe: URL Regular Expression f... Pin
Guffa28-Nov-08 20:36
Guffa28-Nov-08 20:36 
AnswerRe: URL Regular Expression f... Pin
Garth J Lancaster28-Nov-08 23:49
professionalGarth J Lancaster28-Nov-08 23:49 
QuestionConverting byte[] to a stream Pin
darkzangel28-Nov-08 18:17
darkzangel28-Nov-08 18:17 
GeneralRe: Converting byte[] to a stream Pin
Luc Pattyn28-Nov-08 18:32
sitebuilderLuc Pattyn28-Nov-08 18:32 
Hi,

the way I usually transfer large amounts of data between a managed (C#) app and some unmanaged (C) code, is as follows:

1. have the managed code allocate a buffer of sufficient size; it could be a byte array in your case.
2. Use GCHandle class to first pin it down, then obtain a pointer to it.
3. Pass the pointer to the native code to get it read and/or written to.
4. Upon return, free the GCHandle and start using the buffer in the managed world.

In summary: no extra copies are made, and Marshal and MemoryStream classes are avoided.

Hope this helps.

Luc Pattyn [Forum Guidelines] [My Articles]

Fixturized forever. Confused | :confused:


GeneralRe: Converting byte[] to a stream Pin
darkzangel29-Nov-08 9:32
darkzangel29-Nov-08 9:32 
GeneralRe: Converting byte[] to a stream Pin
Luc Pattyn29-Nov-08 10:35
sitebuilderLuc Pattyn29-Nov-08 10:35 
Questiontime-division multiplexing Pin
Member 391904928-Nov-08 7:26
Member 391904928-Nov-08 7:26 
AnswerRe: time-division multiplexing Pin
User 665828-Nov-08 11:05
User 665828-Nov-08 11:05 
AnswerRe: time-division multiplexing Pin
Guffa28-Nov-08 11:10
Guffa28-Nov-08 11:10 
AnswerRe: time-division multiplexing Pin
Nicholas Butler28-Nov-08 13:22
sitebuilderNicholas Butler28-Nov-08 13:22 
GeneralRe: time-division multiplexing Pin
Dave Kreskowiak28-Nov-08 15:36
mveDave Kreskowiak28-Nov-08 15:36 
GeneralRe: time-division multiplexing Pin
PIEBALDconsult28-Nov-08 16:11
mvePIEBALDconsult28-Nov-08 16:11 
QuestionCan different processes share memory? Pin
Member 391904928-Nov-08 7:25
Member 391904928-Nov-08 7:25 
AnswerRe: Can different processes share memory? PinPopular
J. Dunlap28-Nov-08 9:50
J. Dunlap28-Nov-08 9:50 
Questionc# source code and produces the source code in S-style(Banner Style) indentation Pin
sp198428-Nov-08 6:48
sp198428-Nov-08 6:48 
AnswerRe: c# source code and produces the source code in S-style(Banner Style) indentation Pin
EliottA28-Nov-08 6:57
EliottA28-Nov-08 6:57 
AnswerRe: c# source code and produces the source code in S-style(Banner Style) indentation Pin
Thomas Weller28-Nov-08 6:57
Thomas Weller28-Nov-08 6:57 
AnswerRe: c# source code and produces the source code in S-style(Banner Style) indentation Pin
Ashfield28-Nov-08 8:48
Ashfield28-Nov-08 8:48 
GeneralRe: c# source code and produces the source code in S-style(Banner Style) indentation Pin
Wendelius28-Nov-08 8:59
mentorWendelius28-Nov-08 8:59 
AnswerRe: c# source code and produces the source code in S-style(Banner Style) indentation Pin
Christian Graus28-Nov-08 16:15
protectorChristian Graus28-Nov-08 16:15 
QuestionKeyboard shortcuts Pin
nlowdon28-Nov-08 3:06
nlowdon28-Nov-08 3:06 

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.