|
I would make the code look like this:
private void panel13_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
ArrayList nodes = new ArrayList();
StreamReader sr = File.OpenText("C:\\NeckingRa\\Temp\\cut.dat");
String line;
while ((line=sr.ReadLine())!=null)
{
string[] values = line.Split(' ');
nodes.AddRange(values);
}
sr.Close();
} The file variable is not needed and inside of the while look you were reading to the end of the file. Also you had never added the data in values to the nodes variable. I also like using @"c:\NeckingRa\Temp\cut.dat" in C# instead of the normal \\ that we all had to use in C++.
Steve Maier, MCSD MCAD
|
|
|
|
|
How to check if the thread is over? Then I can quit application.
|
|
|
|
|
You can wait for the thread to stop:
myThread.Join()
If you don't want to block the application, but display a warning, you can use Thread.Join to check the thread's state:
<br />
if( myThread.Join(1) ){<br />
}<br />
else{<br />
MessageBox.Show("There is still a running thread.");<br />
}<br />
|
|
|
|
|
i want to acquire an object`s Name property at run time.
(in example : this.Name)
thank.
|
|
|
|
|
TehMedic wrote:
i want to acquire an object`s Name property at run time.
(in example : this.Name)
You need to check into reflection, in particular the PropertyInfo[^] class. Given an Assembly you can iterate through all the Type 's by calling GetTypes() and for each Type call GetProperties() . One of the members of the PropertyInfo class is Name .
- Nick Parker My Blog | My Articles
|
|
|
|
|
thanks for your help.
I test your approach , for some control it work properly
but when use it for a component it return null.
?
|
|
|
|
|
I got a problem when using property grid:
I defined a class named ExampleClass with some properties.Then I did as follows:
ExampleClass myObject = new ExampleClass(...);
PropertyGrid myPropertyGrid = new PropertyGrid();
myPropertyGrid.PropertySort = PropertySort.Categorized;
myPropertyGrid.SelectedObject = myObject;
I would like the properties of myObject to be displayed in the property grid in the special order as I expected.Howerver,it didn't work.What should I do to achieve my purpose?
SOS,thank you!
|
|
|
|
|
|
Of course.
for each property of ExampleClass,Category attribute is attached.Problem does not lie here.I just want to properties of ExampleClass's object to be shown in property grid in some special order.Take properties A,B,C for example,A,B,C might be written in the code of class ExampleClass as follows:
public class ExampleClass{
...
public TypeB B { get {...} set {...} }
public TypeA A { get {...} set {...} }
public TypeC C { get {...} set {...} }
...
}
(ps:all required attributes have been already attached to A,B,C)
the special order I want to see is B first ,then A and C last in the property grid.of course,I set myPropertyGrid.PropertySort = PropertySort.Categorized.Now,you see,where the problem actually lies?
|
|
|
|
|
I have a C++ WinSock based client-server system which has the following design:
Client:
a. For each request, client connects to the server
b. Sends the input data
c. Waits for response (During this server does the processing and sends output)
d. Presents the results to the client
e. Socket connection is broken
Server:
a. Server waits in listen() loop
b. For each request, it spawns a thread
c. De-serializes input data
d. Does business logic and database operations
e. Transfers output to the client
Basically it is a synchronous multi-threaded socket based client-server solution with a simple design and adequate scalability. We have used it for years for upto 10 concurrent users and constant request-response cycles. Note that the request and response may consist of fairly large (e.g. 10 to 100 MB) files also.
Now we are re-designing the software with C#... I would like to know the optimal way to design the system, so that it is highly scalable. Please give your suggestions.
Thanks a lot !
|
|
|
|
|
The only suggestion I have is to use a ThreadPool on the server instead of spawning a thread directly. Threads tend to have high overhead for launching.
--
Joel Lucsy
|
|
|
|
|
I recommend going with either Web Services or .NET Remoting over HTTP hosted by IIS (which is exposed as a Web Service, so it's still one-way request/response). Scalability is handled by IIS leaving you with the higher-level functionality.
I also recommend implementing the WSE (http://msdn.microsoft.com/webservices/building/wse[^]) and using DIME to transfer files. It's a very simple API and does not require that the documents are serialized to a byte[] array like when you transfer it over the wire using Web Services or .NET Remoting. It's a binary wire format, and an industry standard to boot.
I recommend this because writing a socket client/server system and doing the serialization yourself is fine, but there's functionality for that already in the .NET BCL through Web Services and .NET Remoting.
Besides, Web Services are also an industry standard and open up new client possiblities that may otherwise be more difficult with a standard socket server (have to take endianess and packing into account).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Like Heath said, use a web service but we found that DIME
wasn't very good at handling large documents since it could
not stream. possibly u can use a webservice which returns
a http url of the file to be transfered. The client
receives the url and uses http protocol to download the
file. U can google for software which will help u to
download using http protocol
ex: sharpdownload project--sourceforge.net )
cool man
|
|
|
|
|
You can chunk large files using DIME - it's part of the specs.
Why does he need extra software to download files via HTTP? The .NET Framework BCL already has this. Use WebClient.DownloadFile for the simple way, or use HttpWebRequest and HttpWebResponse for a little more control and feedback. There's no need for an extra library. It's simply a waste.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
We found that WebClient.DownloadFile or HttpWebRequest and HttpWebResponse
has problems when the user is using proxy. we tried
using proxy class to supply relevent
information that also did not work.
Further the download seemed faster with
the extra library since it downloaded
parts of the file (using threads) and joined them later.
we dint have any problems with the proxy also.
Does the BCL classes also implement the
same?
cool man
|
|
|
|
|
I don't remember off the top of my head, but I believe that was fixed in .NET 1.0 SP2. I know it's not in the list of fixes for .NET 1.0 SP3 & .NET 1.1 SP1 (I got on this team at the time of their release).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
How to trim unnecessary white space whith in two strings using regular expressions?
|
|
|
|
|
Try the following:
string sentence = "Hello my name is Nick.";
string text = Regex.Replace(sentence, "\\s+", "");
Console.WriteLine(text);
- Nick Parker My Blog | My Articles
|
|
|
|
|
Hi friends,
I am trying to copy stream of chars from file to buffer(char[]) by following code :
char[] cbufferi = new char[2000];
FileStream f=new FileStream
("test.dbf",FileMode.Open,FileAccess.Read);
BinaryReader br = new BinaryReader(f);
cbufferi = br.ReadChars(2000);
BUT method br.ReadChars(2000) reads only ASCII chars and it neglects NON-ASCII (char with value>127) and hence data stored in cbufferi is inaccurate. I am trying to read header of DBF files and then I want to further process header afterwards. Please let me know how can I read header of file so that it contains ACCURATE data ie. ASCII/NON-ASCII data.
Thanks for your help..
|
|
|
|
|
Did you try this:
<br />
byte[] buffer = new byte[2000];<br />
f.Read(buffer, 0, 2000);<br />
char cbuffer = Encoding.Default.GetChars(buffer);<br />
|
|
|
|
|
Hi John,
Hey Great... this worked. Thank you very very much for the help.
|
|
|
|
|
hi,
How can i cast datasource of a datagrid to a datatable.
I tried this block for that. But no result
DataTable dt=((DataTable)this.MicroGrid.DataSource) as DataTable;
Do u have any idea ?
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Actually, the code should be:
DataTable dt = (DataTable)MicroGrid.DataSource;
You might want to check the type of the DataSource before you attempt to cast it to a DataTable. Not all DataSource s can be cast to a DataTable ...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hi,
Did you checked whether your answer is good enough to serve my purpose ?
Dear it is not working and i am getting a an error " specified cast is not valid ".
code block :
MicroGrid.Datasource=dataset.Table["xyz"].DefaultView;
DataTable dt = (DataTable)MicroGrid.DataSource;
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
sreejith ss nair wrote:
Did you checked whether your answer is good enough to serve my purpose ?
$#@*^@$$... Like I told you in my previous post. CHECK THE TYPE of DataSource before you try and cast it to a DataTable. Your DataSource is bound to a DataVIEW, not a table. You can't cast a DataView to a DataTable, so therefore, yes, "The specified cast is not valid."
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|