Click here to Skip to main content
15,915,027 members
Home / Discussions / C#
   

C#

 
AnswerRe: Which timer's callback is on a separate thread? Pin
jschell21-Jul-11 8:54
jschell21-Jul-11 8:54 
AnswerRe: Which timer's callback is on a separate thread? Pin
Dave Kreskowiak21-Jul-11 9:04
mveDave Kreskowiak21-Jul-11 9:04 
GeneralRe: Which timer's callback is on a separate thread? Pin
Jun Du21-Jul-11 9:21
Jun Du21-Jul-11 9:21 
GeneralRe: Which timer's callback is on a separate thread? Pin
Dave Kreskowiak21-Jul-11 10:00
mveDave Kreskowiak21-Jul-11 10:00 
AnswerRe: Which timer's callback is on a separate thread? Pin
DaveyM6921-Jul-11 9:15
professionalDaveyM6921-Jul-11 9:15 
AnswerRe: Which timer's callback is on a separate thread? Pin
Shameel21-Jul-11 9:42
professionalShameel21-Jul-11 9:42 
AnswerRe: Which timer's callback is on a separate thread? Pin
Luc Pattyn21-Jul-11 17:29
sitebuilderLuc Pattyn21-Jul-11 17:29 
QuestionDelphi 6 code vs C# conversion question Pin
Aurbo721-Jul-11 4:12
Aurbo721-Jul-11 4:12 
So far this appears to have stumped a lot of folks, including myself.

The function in Delphi works correctly, the function in C# is crashing with managed/unmanaged errors.

using a delphi.pas generated mrdsio.dll file, the Receive(Adr,Len) is sent on to the mrdsio.dll for processing (mrdsio.dll sends and retrieves data to an mcu epprom memory bank with Adr as Address and Len as Length)

The Tdata (single dimension byte array) is returned from the mrdsio.dll and processed as Data.

Again, Delphi code works, C# fails.

any clues?


original Delphi Code:
type<br />
  TData = array [0..255] of byte;<br />
<br />
function Receive(Adr, Len: integer): TData; stdcall; external 'mrdsio.dll';<br />
<br />
procedure TForm1.Button5Click(Sender: TObject);<br />
var Data: TData;<br />
    i: integer;<br />
    s: string;<br />
begin<br />
if not (CheckBox1.Checked) then<br />
  begin StatusBar1.SimpleText:='Bidirectional operation not allowed'; exit; end;<br />
for i:=0 to 255 do Data[i]:=0;<br />
Data:=Receive($02,8);<br />
if (Data[1]=0) then<br />
  begin StatusBar1.SimpleText:='Failed, check Connection'; exit; end;<br />
s:='';<br />
for i:=1 to 8 do<br />
  s:=s+Chr(Data[i+1]);<br />
Edit1.Text:=s;<br />
end;



Converted C# code;

[DllImport("mrdsio.dll", EntryPoint="Receive", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]<br />
public static extern byte[] Receive(int Adr,int Len);<br />
<br />
private void btnRX_Click(object sender, EventArgs e)<br />
           {<br />
            byte[] Data = new byte[256];<br />
            int i;<br />
            string s;<br />
            int Adr = 0x02;<br />
            int Len = 8;<br />
            for (i = 0; i <= 255; i++) Data[i] = 0;<br />
                Data = DLL.Receive(Adr, Len);<br />
            s = " ";<br />
            for (i = 1; i <= 8; i++)<br />
                s = s + Data[i + 1].ToString();<br />
            txtBox1.Text = s;<br />
           }<br />

AnswerRe: Delphi 6 code vs C# conversion question Pin
Richard MacCutchan21-Jul-11 4:38
mveRichard MacCutchan21-Jul-11 4:38 
GeneralRe: Delphi 6 code vs C# conversion question Pin
Aurbo721-Jul-11 4:49
Aurbo721-Jul-11 4:49 
GeneralRe: Delphi 6 code vs C# conversion question Pin
Richard MacCutchan21-Jul-11 6:34
mveRichard MacCutchan21-Jul-11 6:34 
GeneralRe: Delphi 6 code vs C# conversion question Pin
DaveyM6921-Jul-11 7:48
professionalDaveyM6921-Jul-11 7:48 
GeneralRe: Delphi 6 code vs C# conversion question Pin
Aurbo721-Jul-11 8:09
Aurbo721-Jul-11 8:09 
GeneralRe: Delphi 6 code vs C# conversion question Pin
DaveyM6921-Jul-11 9:30
professionalDaveyM6921-Jul-11 9:30 
GeneralRe: Delphi 6 code vs C# conversion question Pin
Aurbo721-Jul-11 10:30
Aurbo721-Jul-11 10:30 
GeneralRe: Delphi 6 code vs C# conversion question Pin
BobJanova22-Jul-11 2:32
BobJanova22-Jul-11 2:32 
AnswerRe: Delphi 6 code vs C# conversion question Pin
BobJanova22-Jul-11 2:31
BobJanova22-Jul-11 2:31 
GeneralRe: Delphi 6 code vs C# conversion question Pin
Aurbo722-Jul-11 4:45
Aurbo722-Jul-11 4:45 
Questioncrystal reports running total problem. Pin
Asif Rehman21-Jul-11 3:27
Asif Rehman21-Jul-11 3:27 
QuestionWhat is best for Parent Child List Pin
Anubhava Dimri20-Jul-11 23:38
Anubhava Dimri20-Jul-11 23:38 
AnswerRe: What is best for Parent Child List Pin
#realJSOP21-Jul-11 0:16
professional#realJSOP21-Jul-11 0:16 
GeneralRe: What is best for Parent Child List Pin
Anubhava Dimri22-Jul-11 0:16
Anubhava Dimri22-Jul-11 0:16 
AnswerRe: What is best for Parent Child List Pin
OriginalGriff21-Jul-11 2:09
mveOriginalGriff21-Jul-11 2:09 
GeneralRe: What is best for Parent Child List Pin
#realJSOP21-Jul-11 2:31
professional#realJSOP21-Jul-11 2:31 
GeneralRe: What is best for Parent Child List Pin
Anubhava Dimri22-Jul-11 0:20
Anubhava Dimri22-Jul-11 0: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.