Click here to Skip to main content
15,921,697 members
Home / Discussions / C#
   

C#

 
GeneralHTML Processing in Windows Application Pin
Inam27-Oct-03 7:25
Inam27-Oct-03 7:25 
GeneralRe: HTML Processing in Windows Application Pin
Heath Stewart27-Oct-03 8:12
protectorHeath Stewart27-Oct-03 8:12 
Generalform object's constructor Pin
coolerbob27-Oct-03 6:30
coolerbob27-Oct-03 6:30 
GeneralRe: form object's constructor Pin
Heath Stewart27-Oct-03 6:39
protectorHeath Stewart27-Oct-03 6:39 
GeneralHelp richtextbox Pin
Wyetela27-Oct-03 6:08
Wyetela27-Oct-03 6:08 
GeneralActive X objct into web project Pin
@LX27-Oct-03 6:00
@LX27-Oct-03 6:00 
GeneralRe: Active X objct into web project Pin
Heath Stewart27-Oct-03 6:29
protectorHeath Stewart27-Oct-03 6:29 
QuestionThreading using the ref statement? Wha Happen? Pin
jremignanti27-Oct-03 5:23
jremignanti27-Oct-03 5:23 
Has anyone noticed anything strange happening when you try to use the ref statement to pass a parameter while in a sub-thread?

Here's what I did:
<br />
public void ThreadProc()<br />
{<br />
    byte[] data=new byte[7];<br />
    data[0]=0;<br />
    data[1]=0;<br />
    data[2]=1;<br />
    data[3]=0;<br />
    data[4]=1;<br />
    data[5]=7;<br />
    data[6]=7;<br />
<br />
    chip1.WriteSPI(ref data[0], 7);<br />
}


where ThreadProc is called when I start a new thread:
<br />
thread1=new System.Threading.Thread(new ThreadStart(ThreadProc));<br />
thread1.Priority=System.Threading.ThreadPriority.Lowest;<br />
thread1.Start();


chip1.WriteSPI(ref byte datain, datasize) calls a COM object method that writes a stream of bytes on the USB port to a device downstream. It uses the reference as a pointer to the byte array.

All of this works fine in the main part of my app, but when I try to put it in a separate thread it writes garbage data to the port (actually it keeps writing the same garbage data every time). Has anyone done anything like this? Please feel free to point out my gross ignorance where appropriate.

Thanks
JR
AnswerRe: Threading using the ref statement? Wha Happen? Pin
Heath Stewart27-Oct-03 6:35
protectorHeath Stewart27-Oct-03 6:35 
GeneralRe: Threading using the ref statement? Wha Happen? Pin
jremignanti27-Oct-03 8:00
jremignanti27-Oct-03 8:00 
GeneralRe: Threading using the ref statement? Wha Happen? Pin
Heath Stewart27-Oct-03 8:05
protectorHeath Stewart27-Oct-03 8:05 
GeneralRe: Threading using the ref statement? Wha Happen? Pin
jremignanti27-Oct-03 8:28
jremignanti27-Oct-03 8:28 
GeneralRe: Threading using the ref statement? Wha Happen? Pin
Heath Stewart27-Oct-03 8:34
protectorHeath Stewart27-Oct-03 8:34 
GeneralRe: Threading using the ref statement? Wha Happen? Pin
jremignanti27-Oct-03 9:02
jremignanti27-Oct-03 9:02 
GeneralRe: Threading using the ref statement? Wha Happen? Pin
Heath Stewart27-Oct-03 10:08
protectorHeath Stewart27-Oct-03 10:08 
GeneralRe: Threading using the ref statement? Wha Happen? Pin
jremignanti27-Oct-03 10:36
jremignanti27-Oct-03 10:36 
GeneralRe: Threading using the ref statement? Wha Happen? Pin
Heath Stewart27-Oct-03 10:43
protectorHeath Stewart27-Oct-03 10:43 
GeneralRe: Threading using the ref statement? Wha Happen? Pin
jremignanti27-Oct-03 10:54
jremignanti27-Oct-03 10:54 
GeneralRe: Threading using the ref statement? Wha Happen? Pin
Heath Stewart27-Oct-03 10:55
protectorHeath Stewart27-Oct-03 10:55 
GeneralRe: Threading using the ref statement? Wha Happen? Pin
jremignanti27-Oct-03 11:17
jremignanti27-Oct-03 11:17 
GeneralAllowDrop Property Problem Pin
Volker Jacobsen27-Oct-03 3:14
Volker Jacobsen27-Oct-03 3:14 
GeneralRe: AllowDrop Property Problem Pin
Heath Stewart27-Oct-03 8:44
protectorHeath Stewart27-Oct-03 8:44 
GeneralRe: AllowDrop Property Problem Pin
Volker Jacobsen27-Oct-03 20:46
Volker Jacobsen27-Oct-03 20:46 
GeneralTwo ImageList and two ImageIndex (and maybe... useful source code for you) Pin
god4k27-Oct-03 1:36
god4k27-Oct-03 1:36 
GeneralRe: Two ImageList and two ImageIndex (and maybe... useful source code for you) Pin
Heath Stewart27-Oct-03 2:37
protectorHeath Stewart27-Oct-03 2:37 

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.