|
Also
customers[3]
will return an object which has to be cast to be useful.
Whilst
customers2[3]
will return a Customer
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
ArrayList will be, in many aspects, the same as List<object>.
You can do: customers.Add(1); customers.Add("Test"); and customers.Add(cust);
When you get the value, it will be also a simple "object". So, if the Customer class has a name property, you will only be able to get the customer name doing:
((Customer)customers[0]).Name
instead of
customers2[0].Name
And, of course, you will get an exception if the first item is the 1 I added. But, the problem, you got the exception when getting the item, not when you were putting it into the list.
Also, there is more. For value types (the 1 is a value type) it will avoid boxing.
When you do arrayList.Add(1) it internally creates a full object (or box if you prefer) which contains the effective value type 1, and adds a reference to such box in the list.
If you do integerList.Add(1) (which is List<int>) you will add the 1 to the list. No reference. No additional object created.
|
|
|
|
|
Putting stuff in is fine; the difference is in getting stuff back out.
|
|
|
|
|
Such an eloquent, technically precise response!
|
|
|
|
|
hi guys
i dont know how to make thread in my program , please help me
i wanna know how to make , and work with threads , it`s better to use System.threading.thread
|
|
|
|
|
Thread myThread = new Thread(nameOfTheFunctionToExecuteHere);
myThread.Start();
This is enough to create a new thread and start it. You can, of course, set the name of the thread, the priority etc.
The nameOfTheFunctionToExecuteHere must be in the pattern:
void nameOfTheFunctionToExecuteHere()
{
}
or static void nameOfTheFunctionToExecuteHere()
{
}
You can also use void nameOfTheFunctionToExecuteHere(object parameter) but, in that case, you must call myThread.Start(parameter).
This will create an entire new thread. For small work that does not wait for any external events it is recommented that you use the ThreadPool.
To do that, call ThreadPool.QueueUserWorkItem(methodNameHere);
This will use reutilize the threads from the ThreadPool (it is faster than creating a full thread), but the ThreadPool is limited, so you must not "block undefinitelly" in these threads.
There are other differences, but I think you will find it by yourself.
|
|
|
|
|
After my application (heavy file IO on UNC address) is running a little bit it chrashes always with:
SystemIO Exception: The specified network name is no longer available.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.get_Length()
On this time the Share is also not reachable by explorer, sometimes the compleate system is chrashing,
on reboot I have then to kill the explorer.exe.
I think I use some resources too much. What is the best way to analyse this?
ProcessMonitor?
WinDbg? But how?
Thanks,
daniel
|
|
|
|
|
I don't know the best way to analyse this, but I have a possible solution.
Instead of reading and writing to, say "\\SomeComputer\SomeSharing\..." try creating a Remoting application.
The remoting application server will run in SomeComputer. Then, it always access everything as C:\ D:\ (or the apropriate local drive) and the clients access the remoting server application instead of the drive mapping. I did that when I started to have problems reading and saving files remotelly and all my problems where gone.
|
|
|
|
|
Hi,
I have a inbound named pipe in overlapped mode. The client connects and writes in the pipe created by the server.
The client is writing real-time data very fast in the named pipe, but the server is not reading the data fast enough.
This is creating a delay between what is happening in the real-time application and the data that is given by the read in the server.
If I decrease the rate at which the client writes to the named pipe, I get better results (the real-time application and the data read in the server tend to match) but by decreasing the rate I am not getting smooth data, meaning I am getting samples of data from the real-time application periodically.
On the other hand if I decrease the buffersize in the Named pipe, and the rate of writing to the named pipe is fast, the real-time application drags itself and gets very slow. I am guessing this is because the named pipe gets filled very fast and since it is Overlapped the data cannot be overwritten unless the slow reader finishes reading it.
So my problem is:
Case 1 - (fast write rate, large buffer): server read data and the real-time app are way off
Case 2 - (fast write rate, small buffer): application hangs
Case 3 - (slow write rate, *): server read data is not smooth (not acceptable)
Did anyone face similar problems? All suggestions are much appreciated.
|
|
|
|
|
PS: the blocking mode of the named pipe (one of the options in the third parameter when creating it) is PIPE_WAIT
modified on Wednesday, October 28, 2009 3:47 PM
|
|
|
|
|
I faced the same problem. And, to be honest, I faced another problem. I was using named pipes to communicate between 32bit and 64bit applications, and the data sent was not the same data that was received.
At that time I had created a remoting framework that was capable of using TCP/IP or IPC. I always thought IPC was faster but, after some benchmark, I discovered that TCP/IP was faster and didn't had any problems with 32/64 bits, so I gave up of using IPC.
Also, even in TCP/IP, I had the problem that only one thread can write to the stream. Even using locks before read and write, the internal buffers get lost and I got a lot of exceptions. So, one thing you can try, if you for some reason are using more than one thread to send the packets, is to send all the messages to one thread, and let that thread send the message to the IPC stream.
If this does not solve, try using TCP/IP. As I said, for me it was faster.
|
|
|
|
|
I was thinking in the similar line, using UDP though. Because I don't mind getting few packets dropped as the input stream is very fast. And also because I am thinking the TCP acknowledgments might cause some delays.
Named pipes are supposed to be pretty fast. I went through my code and there is nothing in the server that does huge processing to the received data. An event handler simply reads the data and sends it to another function. I wonder why it is reading slowly.
Did you figure out why yours was reading slowly?
Thank you for your suggestions.
|
|
|
|
|
No. But considering I changed it to TCP/IP and it went faster, I must say it is an IPC problem (maybe the .Net implementation of IPC is the problem). And, considering my primary use was TCP/IP and IPC was only as a "faster" alternative, I simple dropped IPC support.
I think you must try with tcp/ip (or udp, like you said). If it works faster, the problem is in the protocol, not in your code.
|
|
|
|
|
Is there a way to make the System.Windows.Forms.WebBrowser view only? I am currently controlling a WebBrowser programmatically and am allowing the user to "watch" but the user is still able to interact with the control.
I am trying to find a way to disable the user’s ability to interact with the WebBrowser while still being able to view what is inside the control.
Thank you all in advance!
Matt
|
|
|
|
|
Maybe the enabled property?
|
|
|
|
|
Unfortunately, the Enabled property is not supported by the WebBrowser control. =(
Any other ideas?
|
|
|
|
|
|
Hi,
I'm trying to make my own LogonUI.exe (logon user interface[Vista and Windows7]) want to make all of things (login, lock, unlock, shutdown, restart) with my program (win32 form app) but i can't find any resource, article or something like this, can anyone help me a bit?
There is programs making this things, but they're not open source, please help.
Regards.
Orhan "Sehlor" KALAYCI
|
|
|
|
|
Create your exe with those functionality, then replace the value of shell in HKLM\Softwares\Microsoft\WindowsNT\CurrentVersion\Winlogon from explorer.exe to your exe name.
We generally do this to create custom explorer or KIOSK like interface...
Remember to place your exe inside %windir% (drive:\windows)
|
|
|
|
|
i m creating a window application on c# in which i m using crystal report option. I m getting fields data from the dataset, all is going fine but i m not able to increase the size limit of the fieldobject, there is a field in my dataset which is having text more than 500 hundred characters, when i run my application it shows only 500 characters and my whole data is not visible due to that.
so plz can anybody tell me how to increase the size to display text more than 500 characters.
thanks in advance
|
|
|
|
|
Hi,
Create a formula field which has the dataset field containing >500characters. drag it on the report where ever u want to show. right click on the formula field in report and choose format filed under the common tab check on can grow checkbox give ok.
hope this help.
|
|
|
|
|
hey karthik
thanks for ur valueable support
my problem solved now
actually i dont know how to create a formula field but my problem is solved with the help of text object. when i drag n drop the dataset field in the text object it works fine
thanks again
|
|
|
|
|
how nullable type different from normal type.i knew that for nullable type we can assign NULL value(specialy for value types)..i want to know what is the speciality in nullable type so that v can assign NULL to that...i am also want to know nullable types are another type or what?
|
|
|
|
|
This will tell you everything you need.
c# Nullable types[^]
CCC solved so far: 2 (including a Hard One!)
|
|
|
|
|
Nullable Types can take Nulls. Generally Valuetypes couldnt have Null assigned to it, it should always assign default(type)
In case of Nullables, you can assign nulls
int? x = null;
if(x.HasValue)
int y = x.Value; // x.Value will point to original value.
So you can say Nullable types is just a wrapper.
For further Enquery Read Here :
C# 2.0 Nullable Types[^]
Or
Working with Nullable Types in C#[^]
|
|
|
|