|
Thank you Dennis!
I cannot (or rather, would not like to) change the method signature, and as you mentioned, copying each element is slow. But that is what I have settled for (I would end up copying each element in the partitioned byte[] anyway inside Foo), until I - or someone else for that matter - comes up with a quicker solution.
Anyone?
Thanks!
|
|
|
|
|
SebbaP wrote:
I cannot (or rather, would not like to) change the method signature, and as you mentioned, copying each element is slow. But that is what I have settled for (I would end up copying each element in the partitioned byte[] anyway inside Foo), until I - or someone else for that matter - comes up with a quicker solution.
Copying is slower but that does not necessarily mean that it's too slow for you. Although I'd still suggest that you should consider refactoring the method you want to call, you should give Array.Copy() a try. Somehow I doubt that it copies each element. I would rather expect a simple memcopy which should not get you into trouble unless you want to copy a few gigabytes per second. If you take a look at how Array.Copy() works you'll find out that it is implemented directly in the CLR. The method is overloaded however it always results in a call of the following method:
[MethodImpl(MethodImplOptions.InternalCall),
ReliabilityContract(Consistency.MayCorruptInstance, CER.MayFail)]
internal static extern void Copy(Array sourceArray, int sourceIndex,
Array destinationArray, int destinationIndex,
int length, bool reliable);
Best regards
Dennis
|
|
|
|
|
|
Hi,
Purpose: I want to store any web page as html file.
Solution: Call GetResponse to the specified web site and download it.
Code:
public void Download( string url)
{
// Get the URI from the command line.
Uri httpSite = new Uri(url);
// Create the request object.
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(httpSite);
req.ContentType = "text/html";
req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705; .NET CLR 1.1.4322)";
req.KeepAlive = false;
req.ProtocolVersion=HttpVersion.Version11;
req.Method = "GET";
req.AllowAutoRedirect=true;
req.MaximumAutomaticRedirections=100;
req.Timeout=(int) new TimeSpan(0,0,60).TotalMilliseconds;
req.Credentials = CredentialCache.DefaultCredentials;
Stream ResponseStream = null;
HttpWebResponse resp = null;
// Call EndGetResponse, which produces the WebResponse object
// that came from the request issued above.
try
{
resp = (HttpWebResponse)req.GetResponse();
// Find the data size from the headers.
string strContentLength = resp.Headers["Content-Length"];
// Read the content here...
// .....
}
catch(Exception e)
{
Console.WriteLine(e.Message);
}
finally
{
if (ResponseStream != null)
ResponseStream.Close();
}
}
The above function works fine on some websites, but on some website where lots of redirection exists it throws 401 error.
Can somebody throw some light on what might be the root cause of this? I tried many options e.g. setting the authorization code as a part of header etc.
Also if you set Autoredirection propertyl of webrequest to false then it dosen't throw any error but the content returned is empty (0 length).
Thanks,
Anand
|
|
|
|
|
hello,am a new user to C# sharp. when i use a datetimepicker ( format set to short), along with some more controls in a form, the first time i executed the project, Iam able to get the focus in the Datetimepicker control(by pressing tab).
But if u select a new value in the control and use tab again am not getting the focus in datetime control. IS THIS A PATCH IN DATETIME CONTROL?
But when u click on it , the mousedown event makes the selection. so, iam thinking of invoking the mousedown evnet in the Enter Event(when the control is active by pressing tab). But not sure how to do it. or is there any other way of achiveing this?
Please help me at the earliest. Much Thanks.
Regards,Manivannan.P
|
|
|
|
|
Hi,
I have a very strange problem. I'm working with C# on Windows 2000.
The problem involves my module which is a dll.
When I try to debug, when I go over certain lines of code (not always the same one) the program exits and I see in the Output window:
Fatal execution engine error.
The program '[2976] <name>' has exited with code 0 (0x0).
Now to the strange part. It never happens if there are no breakpoints in the code.
It also doesn't happen if I'm running my dll from a test program in the same solution, only from another place.
More clues: What I see is that the debugger reaches the breakpoint, prepares to stop (I see the yellow highlight) and then crashes. It doesn't enter the function in that line. Another clue is that the function is usually a getter of a connection from another class (the connection exists - it is static), but it doesn't crash there if there s no breakpoint on it or if I debug through it. as I said it doesn't enter the function.
It was a bit long, but I will be really glad if someone could help me,
Thanks!
|
|
|
|
|
Hello,I want to be able to highlight a text and then run my program,which will simulate a Ctrl+c action so the text will be inserted into the clipboard.
Thanks in advance!
|
|
|
|
|
Use the SenKeys.Send function, you have to pass by a string which is formatted in a special way. i dont have it in my head, for instance pushing down Alt and down arrow at the same time should be written
SendKeys.Send("%{DOWN}")
% represents Alt
Regards
Hmitosh
|
|
|
|
|
Thanks for the help,but the problem now is that the Ctrl+c is sent to the running application.. let's say I'm using IE,I want to be able to highlight a word,press an icon that will acivate my program which will simulate ctrl+c and insert the selected word from IE to the clipBoard. I read something about changing the focus,is that a valid solution? and how is it done? thanks!
|
|
|
|
|
After getting very good answers on my question regarding "Calling C# functions from a DLL from within unmanaged C++" [^], I successfully decided to do CLR Hosting [^] and quickly got very good results implementing a usable wrapper around that CLR Hosting stuff.
So it all works very good except the startup time when I load the assembly with my code for the very first time only (through (_AppDomain::CreateInstance() ). Subsequent loads into a new host in the same running applications load fast.
Question: Is there a way to speed up creating an assembly instance?
E.g. when I start a .NET only application the application starts instantly, much faster than when I create the instance inside my .NET host. Maybe there is some "default" CLR floating around in the Windows system that I can re-use inside my .NET host instead of creating a new one?
--
Affordable Windows-based CMS: www.zeta-producer.com
|
|
|
|
|
Hey...I downloaded some code that uses System.Winform but my system complains that a Winform doesn't exist in the Sytem namespace.
I downloaded the .NET 2.0 Beta and the .NET SDK and it still doesn't exist. Where does the Winform object come from?
|
|
|
|
|
|
Hi,
Well, i have 4 Threads, they call the same function to send a File using HttpWebRequest.
I need to send the four photos at the same time.
The function is called at the same time, but only sends 2 at same time :\
Why?
<br />
byte[] buffer = new Byte[256]; <br />
int bytesRead = 0;<br />
while ( (bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0 )<br />
{<br />
requestStream.Write(buffer, 0, bytesRead);<br />
<br />
progress.Value += bytesRead;<br />
}<br />
Thanks.
|
|
|
|
|
|
There is actually a registry hack for it.
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]<br />
"MaxConnectionsPer1_0Server"=dword:00000019<br />
"MaxConnectionsPerServer"=dword:00000019
That should allow up to 10 simultaneous streams.
|
|
|
|
|
Or more specifically i want to get rid of the systemsound when the cursor is in a textbox and you hit the enter key, windows will automaticly play a soundeffect according to the soundeffect that is selected as standardsound (see controlpanel -> Sound and Sound devices -> Scroll down to Standard sound option). I suppose this sound can be useful when you want to notify the user, that the enter key is not applicable in a textbox, in my case however the enter key is supposed to work as an alternative to the tabkey. So in this case it's very annoying having to listening to that soundeffect each time.
I can always deselect the sound from the soundsetting dialogue in controlpanel, however this selection will reflect the whole system and remove the sound in all other cases where this sound occurs and that is not my intention, i just want to remove it from my application. Does anyone know how to solve this?
|
|
|
|
|
Not exactly the easiest thing in the programming world:
Read this[^] to understand how system sound notification occurs and (maybe) how to prevent them.
Yes, even I am blogging now!
|
|
|
|
|
I wouldn't go into changing sound events in the host's OS. Best solution is creating an inherited TextBox and overriding the ProcessDialogKey method:
public Class MyTextBox: TextBox
{
...
protected override bool ProcessDialogKey(Keys keyData)
{
if (keyData==Keys.Enter)
{
if (!this.Multiline)
{
ProcessDialogKey(Keys.Tab);
return true;
}
}
return base.ProcessDialogKey (keyData);
}
...
}
This will enable the enter key as a Tab input. I think its what ur looking for. Just add MyTextBoxes to your form instead of normal TextBoxes and ur all set.
|
|
|
|
|
That is beautiful Skynryd, that really solved my problem.
Thanks a lot
Regards
Hmitosh
|
|
|
|
|
Welcome
|
|
|
|
|
Hello,
I have the following query below that l want executed using crystall reports from the form by clicking on a button.
In VB 6 this was very easy to do with the datareport as you could execute any type of query on the form and display it in the datareport. But l am not sure how to do this in crystall report.
Is there anyway to write this query behind a command button and pass it to the crystall report. I hope you understand what l mean.
string queryOverdueBooks = @"SELECT RefNumber, Title, DateOut, DateDue
FROM Book
WHERE DateDue < '" + currentDate +"' ";
Many thanks in advance,
Steve
|
|
|
|
|
I am hoping to use #Develop to write some C# code but am struggling to get started. Where can I get information on things like "Windows Forms & Properties" - ie Syntax, Use, Descriptions and Modifiers?
Are there other such references that I will need to be aware of (and if so where do I find them) - eg Graphics, File Handling, etc.
My programming experience to date has been Fortran, Pascal, Basic some C and some Assembler - this is my first foray into the realm of IDE and C#
Any advice/help/pointers would be gratefully appreciated.
Many Thanks,
NagaJim
|
|
|
|
|
|
Hello,
I'm a c#.NET developer and I want to have a toolbar control in my application that has a transparented background. Can I do it? I know that the toolbar doesn't support the transparented BackColor property. Is there another way to do it?
Thanks
|
|
|
|
|
Maybe you can try creating a custom toolbox control using group boxes or panels. Both support transparency.
|
|
|
|