|
Test it. It really is the way I wrote. I mean I don't see any reason why Control.Invoke(delegate Method); should for any reason make calling method to return whatever the delegate returns. It does just doesn't make any sense. Execution continues. It just blocks until delegate completed.
zilo
|
|
|
|
|
Hello Zilo,
Just testet it, and have to say THANK YOU SO MUCH for pointing that out.
First of all, I was not consistend in my Projects.
And second, I was completely wrong.
Thats what I like at CP.
By answering (or trying to do so at least), you also get support!
Got my '5'.
Thanks again!
All the best,
Martin
|
|
|
|
|
np,
It's good to know that you know something ) . I wasn't sure either about this one.
zilo
|
|
|
|
|
I was also thinking on similar lines what I actually did was
<br />
if (this.list.InvokeRequired)<br />
{<br />
ListFocusCallBack d = new ListFocusCallBack(listFocused);<br />
Object obj = this.list.Invoke(d, new object[] {});<br />
<br />
if( obj.Equals(Boolean.TrueString ))<br />
return true;<br />
return false;<br />
}<br />
else<br />
{<br />
return this.list.Focused;<br />
}<br />
Your solution about converting Object to bool as (bool)obj never came to my mind. I never knew it was possible.
Thanks...
The Show Ain't Over Yet...
|
|
|
|
|
it send data to tcp/ip port number, ex 8080, now i want to write socket program to read data from that port. Any body help me? How can i do that?
plz post the code
|
|
|
|
|
No more comment!
All the best,
Martin
|
|
|
|
|
Couldn't agree more....
Standards are great! Everybody should have one!
|
|
|
|
|
Try here [^]. You will surely get the kind of help you want.
I will use Google before asking dumb questions
|
|
|
|
|
I'm doing this just to prevent you from posting continuous new threads on this forum. Use this [link] . It an old post of mine to another problem, there you have a code sample to get you started. And next time search CodeProject and Google, get you hands dirty and when you're stuck come here and post question; if you want code use the link I gave you earlier.
I will use Google before asking dumb questions
|
|
|
|
|
I'm sorry, but which bit of we aren't here to do your job for you is so hard to understand? If you can't cope with a task like this, with the advice you've already been given, then I would consider a career change to one where the only questions you need to ask is
"Do you want fries with that?"
|
|
|
|
|
Pete O`Hanlon wrote: f you can't cope with a task like this, with the advice you've already been given, then I would consider a career change to one where the only questions you need to ask is
"Do you want fries with that?"
Nice one.
I will use Google before asking dumb questions
|
|
|
|
|
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"This time yesterday, I still had 24 hours to meet the deadline I've just missed today."
|
|
|
|
|
|
Hello
I'm stuck with a C++ (or something) Dll that i'm supposed to call from a c# App.
(or even "better" from a vb.net app )
The header file says something like
int Initialize([in]unsigned int SlotID, [in]unsigned char* Label, [in]unsigned char* Pin, [in/out]void* hSession);
this
[DllImport("MyDll.dll",EntryPoint="Initialize", ExactSpelling=true, SetLastError=true)]
private extern static void Init(uint SlotID, string Label, string Pin, out IntPtr Handle);
doesn't work at all. it tells me that the target caused an error.
now i tried to marshal the types like
[DllImport("MyDll.dll",EntryPoint="Initialize", ExactSpelling=true, SetLastError=true)]
private extern static void Init([MarshalAs(UnmanagedType.U4)]uint SlotID, [MarshalAs(UnmanagedType.LPStr)]string Label, [MarshalAs(UnmanagedType.LPStr)]string Pin, out IntPtr Handle);
this gives me an Access Violation and marshalling the strings as LPTStr isn't any better.
my last try to build a fixedString struct for passing to that method
[StructLayout(LayoutKind.Sequential)]
private struct fixedString
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=23)]
string MyString;
}
[DllImport("MyDll.dll",EntryPoint="Initialize", ExactSpelling=true, SetLastError=true)]
private extern static void Init([MarshalAs(UnmanagedType.U4)]uint SlotID, fixedString Label, fixedString Pin, out IntPtr Handle);
well you know... *sigh*
i even tried to make it work with unsave coding but still got access-violations or just with that TargetInvocationException
does anybody have an idea how i could get that thing to work?
thanks in advance
greets
m@u
|
|
|
|
|
If any strings get changed in the unmanaged code you have to use a StringBuilder object.
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"This time yesterday, I still had 24 hours to meet the deadline I've just missed today."
|
|
|
|
|
Thank you. i'll test that as soon as i can
this marshalling thing still confuses me a bit. do i have to tell the clr how to marshal the stringbuilder, or should it work when i leave all the marshalAs attributes away?
m@u
|
|
|
|
|
Hi,
Is the fact that your method return types are different, int vs. void, relevant or is that just a typo in the post.
Alan.
|
|
|
|
|
Hi,
yes that's a typo in the post. sorry.
the problem seems now to be solved. the guy who wrote the library said it's because the library uses delay load (what ever that means...).
we have now a version of the dll that works with c#
thanks
m@u
|
|
|
|
|
Hello,
I am trying to write a service in .NET 1.1 and .NET 2.0 which will catch a event and send it to SQL DB.
The issue is with .NET 1.1 service, the service on .NET 2.0 has no issues and is running without any problems. The service running under .NET 1.1 has a memory leak. I found out that when I use the property "EventLogEntry.Message", .NET 1.1 create for each entry 2 string variables with values "HKLM\System\CurrentControlSet\Services\EventLog". The second string is the same value only on the end of the string is the name of the eventlog file to which a event was written. Does anybody know if this is a bug in the .NET 1.1 framework or do I made a misstake somewere ?
This is a portion my code:
QueryApp = "INSERT INTO " + ComputerName + "_Application" +<br />
" (Category,CategoryString,EventCode,EventType,SourceName,TimeGenerated,TimeWritten,Message,UserName) values " +<br />
"(" + currentEntry.CategoryNumber + ",'" + currentEntry.CategoryNumber.ToString() + "'," + currentEntry.EventID + ",'" + Convert.ToString(currentEntry.EntryType) + "','" + currentEntry.Source +<br />
"','" + currentEntry.TimeGenerated.Month.ToString() + ". " + currentEntry.TimeGenerated.Day.ToString() + ". " + currentEntry.TimeGenerated.Year.ToString() + " " + currentEntry.TimeGenerated.Hour.ToString() + ":" + currentEntry.TimeGenerated.Minute.ToString() + ":" + currentEntry.TimeGenerated.Second.ToString() +<br />
"','" + currentEntry.TimeWritten.Month.ToString() + ". " + currentEntry.TimeWritten.Day.ToString() + ". " + currentEntry.TimeWritten.Year.ToString() + " " + currentEntry.TimeWritten.Hour.ToString() + ":" + currentEntry.TimeWritten.Minute.ToString() + ":" + currentEntry.TimeWritten.Second.ToString() +<br />
"','" + currentEntry.Message.Replace("'", "''") + "','" + currentEntry.UserName + "')";<br />
OleDbCommand commandApp = new OleDbCommand(QueryApp, connection);<br />
commandApp.ExecuteNonQuery();<br />
commandApp.Dispose();<br />
commandApp = null;<br />
QueryApp = null;<br />
if you need to see the whole code just tell me I will pase the whole function.
Thank you
Martin
|
|
|
|
|
hi frns
below is the code snippet i used in my proj actually i'll be giving some decimal value in the textbox input. I want to insert that textbox value into my database table. In the database i used that particular column as datatype decimal with precision 5 and scale 2.
SqlParameter pErrorPoints = new SqlParameter("@ErrorPoints", SqlDbType.Decimal);<br />
pErrorPoints.Value = decimal.Parse(txtPoints.Text.Trim());
if anybody knows the answer please do let me know
regards
sunilwise
|
|
|
|
|
sunilwise wrote: pErrorPoints.Value = decimal.Parse(txtPoints.Text.Trim());
Hi,
these are two ways to do that.
Convert.ToDecimal(txtPoints.Text.Trim()) <br />
<br />
or <br />
<br />
Decimal.Parse(txtPoints.Text.Trim()) <br />
Thanks,
Sun Rays
Rate this post if you like answer.
My Articles
|
|
|
|
|
Sun Rays wrote: Convert.ToDecimal(txtPoints.Text.Trim())
or
Decimal.Parse(txtPoints.Text.Trim())
ok i got it both are working
my thanx to all those have answered my question from the bottom of my heart
|
|
|
|
|
sunilwise wrote: decimal.Parse(txtPoints.Text.Trim());
What is your question ? I see you are doing a conversion here.
|
|
|
|
|
You don't actually need to convert the value to a decimal to use it in a SqlParameter.Value. The conversion is useful to prove that it is a decimal, but isn't actually needed by the system.
|
|
|
|
|
be sure that you wrote only numbers in the TextBox.
or set it in the try catch to see what is the problem
spaps
|
|
|
|