 |
 |
Index ‹ DotNet ‹ Visual C#.Net
|
- Previous
- 1
- Visual C#.Net >> select a file in ExplorerHi,
As part of my Windows application, I need to open a folder
containing a file (fileName is specified in txtFile).
I have no problem opening the folder:
FileInfo info = new FileInfo(txtFile.Text);
string folderName = info.DirectoryName;
System.Diagnostics.ProcessStartInfo prStartInfo = new
System.Diagnostics.ProcessStartInfo;
prStartInfo.FileName = "explorer";
prStartInfo.UseShellExecute = true;
prStartInfo.WindowStyle = ProcessWindowStyle.Normal;
prStartInfo.Arguments = '"' + folderName + '"';
System.Diagnostics.Process.Start(prStartInfo);
But how do I select the file within the opened directory?
Any help is much appreciated.
- 2
- Visual C#.Net >> Getting location in a scrollable pictureboxHi,
I have a scrollable view which contains a picturebox.
I need to get the location of the top let hand corner of the view so I
can draw an icon.
When the picturebox is scrolled vertically I need the icon to remain in
the top left hand corner of the view.
At the moment whenever I scroll the picturebox down, the icon gets
hidden.
Thanks in advance.
private void pictureBox1_Paint(object sender,
System.Windows.Forms.PaintEventArgs e)
{
// Need to get the correct location otherwise the
rectangle will disappear when
// the picture is scrolled up
Rectangle boundingRect = new Rectangle(0, 0, 150, 50);
LinearGradientBrush myLinearGradientBrush = new LinearGradientBrush(
boundingRect,
Color.AliceBlue,
Color.Silver,
LinearGradientMode.ForwardDiagonal);
e.Graphics.FillRectangle(myLinearGradientBrush, boundingRect);
Rectangle rc = boundingRect;
rc.Inflate(-1,-1);
e.Graphics.DrawRectangle(new Pen(SystemColors.Highlight), rc);
}
- 3
- Microsoft Project >> Export to Excel weirdnessProject Server 2003...
When I am on the Project Web Access page, and do Resources --> View Resource
Assignments -->Export Grid to Excel, I get different data in the Excel
spreadsheet than what is showing in the grid on the web page.
1) Tasks that have been deleted from projects are showing in Excel
2) Tasks where the rsource assignments have been changed are showing both
the new and the old asssignments (old assignments can't be found anywhere
else and we don't want them)
How can I fix this?
Thanks!
--
Jim
- 4
- Dotnet >> custom logging sink for logging application blockI have written a custom logging sink for the enterprise library logging
application block (June 2005). I have been able to configure it as expected
from the UI config tool (EntLibConfig.exe).
I have built a console application to test it with and I am getting the
following error message write to the default trace log when I attempt to use
my custom logging sink.
'An error occurred while the Distributor was processing the message. Please
check your configuration files for errors or typos. Verify that your sinks
are reachable (queues exist, permissions are set, database exists, etc...)'
This might be security related can anyone give me the answer on how to fix
this?
I can see from VS that the module for my custom logging sink is loaded at
runtime but I am unable to break into the assembly which indicates to me
that any of the 'LogSink' overridden methods are not being called.
Cheers
Ollie Riches
- 5
- Visual C#.Net >> Drag and Drop into ListviewI am having problems with drag and drop into a listview. I am able to
drag and drop items from within the listview, as well as drag items
from the listview and drop into a picturebox. However, I am not able
to drag the text or image from the picturebox to the listview. In the
listview_dragenter function, I have e.Effects = DragDropEffects.Copy (I
have also tried e.Effects = DragDropEffects.Move, but it does not help
either), which is the same as what I have for the picturebox_dragenter
function. However, when I try to drag from the picturebox to the
listview, the cursor gives the same effect as DragDropEffects.None, and
the listview.DragDrop function never gets called. Does anyone have any
ideas of anything I am doing wrong? Thanks.
- 6
- Winforms >> SetFocus() does not workHi all,
I am having problem setting the focus on a rcihTextBox.
The CanFocus returned false.
Any idea/suggestion to make the SetFocus work would be
greatly appreciated.
Thank you in advance.
regards,
Sean
- 7
- Visual C#.Net >> problem in setting the width of a form to 20Hi !
I am facing a wierd problem in setting the width of a form to 20.
Suppose I create two forms Form1 and Form2.
Form1 is the container, meaning
this.IsMdiContainer = true;
Form2 is child form meaning,
f = new Form2();
f.Location = new Point(200,200);
f.MdiParent = this; //Form1 is the parent
f.Show();
I set the width of my Form2 to 20. Yet when it is displayed on Form1, its
width is much larger, way beyond 100. I checked all the properties for Form2
yet I am not able to get the Form2 of thinner width. FormBorderStyle of
Form2 is none. Is there any trick or am I not setting some property?
Regards,
Paresh.
- 8
- Winforms >> Per pixel alpha blend on control (not on a form)I want to make my control (and it child controls) to be alpha blended (just
like the form can do with Opacity property) but I don't know how to do it.
I attempted to use WS_EX_LAYERED style and SetLayeredWindowAttributes but
when I set this style on the control in CreateParms I got a message error
(Error creating window handle.)
I was also playing with WS_EX_TRANSPARENT style and
ControlStyles.SupportsTransparentBackColor but those methods don¢t make
child controls transparent.
--
Dominik Jeske
- 9
- Winforms >> Write to Appname.exe.configI can use System.Configuration classes:
string dns = ConfigurationSettings["name"];
to access the appSettings configuration
<configuration>
<appSettings>
<add key="name" value="val" />
</appSettings>
</configuration>
Isn't there a Class or Method to write values to the appSettings
or for that matter Custom Configuration settings or
Section Groups?
thanks
- 10
- Visual C#.Net >> Old database system question.For a possible update of an old system, I'm trying to work out how to
connect to a password protected Paradox database table. I've got a
connection string that works with the non-password protected files in the
same directory, but that one protected control file is critical.
Anybody know how to open up a passworded Paradox database file in C#?
Yes, I know the whole thing should be re-written using a better db, but I
don't expect the client to sign off on that this year.
- 11
- Visual C#.Net >> Class design helpHi
I am looking at implementing a Facade architecture in my system. i.e
MyBusinessFacdeSystem and multiple MyBusinessObjects
I want the MyBusinssObject class to only be created by the
MyBusinessFacdeSystem class.
i.e
using System;
namespace FacadeTest.MyFacade
{
/// <summary>
/// Summary description for MyFacadeSystem.
/// </summary>
public class MyFacadeSystem
{
private MyBusinessObject_MyBusinessObject = null;
public MyFacadeSystem()
{
_MyBusinessObject= new MyBusinessObject();
}
public MyBusinessObjects MyBusinessObjectsBLL
{
get
{
return _MyBusinessObjects;
}
}
}
}
How do I set the accessability if the MyBusinessObject class i.e.:
using System;
namespace FacadeTest.MyFacade
{
/// <summary>
/// Summary description for MyBusinessObject .
/// </summary>
internal class MyBusinessObject
{
public MyBusinessObject ()
{
}
public string SomeMethod(){
return "Hello";
}
}
}
Hope that is clear,
S
- 12
- Visual C#.Net >> Need I free the memory allocated in unmanaged code?In the Pinvoke example, I find the following example:
unmanaged code:
extern "C" PINVOKELIB_API char* TestStringAsResult()
{
char* result = (char*)CoTaskMemAlloc( 64 );
strcpy( result, "This is return value" );
return result;
}
managed code:
public class LibWrap{
[ DllImport( "..\\LIB\\PinvokeLib.dll" )]
public static extern String TestStringAsResult();
}
String str = LibWrap.TestStringAsResult();
the memory is allocated in unmanaged code, need I free the memory allocated
in managed code? if so, how to free it?
thanks in advance!
- 13
- Visual C#.Net >> How to draw a rectangle on AxWebBrowser to high light one html element?Hi,
Now I can get the rectangle to draw, but it seems the rectangle is not
visible. The following code is used to draw the rectangle. Hope someone can
help. Thanks very much!
SolidBrush brush = new
System.Drawing.SolidBrush(System.Drawing.Color.Red);
Pen pen = new Pen(brush, 4);
Graphics formGraphics = Graphics.FromHwnd(this.axWebBrowser.Handle);
formGraphics.DrawRectangle(pen, rect);
- 14
- Net Framework >> DataGrid / FlexGrid - Expand/Collapse rowsHi everyone,
Can anyone advice me of a way to emulate the Tree Control by the use of
DataGrid for Web forms?
What I would ideally like to do is to have Summary rows with details rows
hidden until such time that the user clicks a particular Summary row.
Clicking it again will hide the details rows (collapse).
I thought of dynamically adding rows to the DataGrid by querying the
database using the selected row's ID but it seems this option will chew up
lots of resources.
Any suggestions are gladly welcomed.
- 15
- Visual C#.Net >> C#/VS and Access Data Engine?Is the Access Data Engine part of the VS/.net install.
Eg. I need to write a stand alone Form app for which a small DB would
be helpful. IN VB 6, I would use ADO to call the Access engine. I
know that OLE is part of C# v1.1,but does MS ship the single engine as
part of the install? If not, can I download it and install it? If
yes, what am I looking for on the MS web site?
Thanks
|
| Author |
Message |
BVinson

|
Posted: Thu Jun 03 05:20:44 CDT 2004 |
Top |
Visual C#.Net >> Order Text as Numbers
Hi,
I am currently writing a requirements gathering system which which
have requirement values of 1.1, 1.1.2, 1.1.3, 2.3.4.5 etc etc.
This works fine stored as varchar in SQL Server 2000 until I want to
sort it in a .Net datagrid. As soon as I reach 10, it obviously puts
the record down with the 1's and I am guessing 20 will go with the 2's
etc etc.
Can anyone suggest a way of getting round this - I know it is because
of the details being stored as text but I need some sort of solution.
Thanks
DotNet208
|
| |
|
| |
 |
Morten

|
Posted: Thu Jun 03 05:20:44 CDT 2004 |
Top |
Visual C#.Net >> Order Text as Numbers
Hi Dave,
You could create a struct out of a single string for the text and have the struct implement IComparable. Putting the structs inside any list with a Sort method should sort it according to your needs.
The CompareTo method will be called on each object to determine if it is "larger" or "smaller" or "equal" to some other object.
ArrayList list = new ArrayList();
RequirementNumber r = new RequirementNumber();
r.Number = "1.1";
list.Add(r);
r = new RequirementNumber();
r.Number = "1.10";
list.Add(r);
r = new RequirementNumber();
r.Number = "1.2";
list.Add(r);
r = new RequirementNumber();
r.Number = "1.1.1";
list.Add(r);
list.Sort();
The list will now be
1.1
1.1.1
1.2
1.10
If this is not the way you want it sorted, just changed the code to what you need.
public struct RequirementNumber : IComparable
{
public string Number;
public int CompareTo(object o) // this method will be called by Sort()
{
if(!(o is RequirementNumber))
return -1;
RequirementNumber temp = (RequirementNumber)o;
string[] local = Number.Split(new char[]{'.'});
string[] remote = temp.Number.Split(new char[]{'.'});
int[] numlocal = new int[local.Length];
int[] numremote = new int[remote.Length];
for(int i = 0; i < local.Length; i++)
{
string s = (string)local[i];
try
{
numlocal[i] = Int32.Parse(s);
}
catch
{
numlocal[i] = 0;
}
}
for(int i = 0; i < remote.Length; i++)
{
string s = (string)remote[i];
try
{
numremote[i] = Int32.Parse(s);
}
catch
{
numremote[i] = 0;
}
}
for(int i = 0; i < numlocal.Length; i++)
{
if(numlocal[i] < numremote[i]) // X.1.X < X.2.X
return -1;
else if(numlocal[i] > numremote[i]) // >
return 1;
// else equal and we need to check the next step
if(i == numremote.Length -1) // X.X > X.X.X
return 1;
}
if(numremote.Length > numlocal.Length) // X.X.X < X.X
return -1;
return 0; // numbers are equal
}
}
Happy coding!
Morten Wennevik [C# MVP]
|
| |
|
| |
 |
Uri

|
Posted: Thu Jun 03 08:24:43 CDT 2004 |
Top |
Visual C#.Net >> Order Text as Numbers
assuming there are never more than 99 sub-requirements for a single
requirement, you can store them in the database as System.Decimal:
1.1 -> 1.01
1.1.2 -> 1.0102
1.1.3 -> 1.0103
2.3.4.5 -> 2.030405
etc.
then they will be sorted correctly.
Dave wrote:
> Hi,
>
> I am currently writing a requirements gathering system which which
> have requirement values of 1.1, 1.1.2, 1.1.3, 2.3.4.5 etc etc.
>
> This works fine stored as varchar in SQL Server 2000 until I want to
> sort it in a .Net datagrid. As soon as I reach 10, it obviously puts
> the record down with the 1's and I am guessing 20 will go with the 2's
> etc etc.
>
> Can anyone suggest a way of getting round this - I know it is because
> of the details being stored as text but I need some sort of solution.
>
> Thanks
|
| |
|
| |
 |
Ignacio

|
Posted: Thu Jun 03 08:11:46 CDT 2004 |
Top |
Visual C#.Net >> Order Text as Numbers
Hi,
I think there is a better way of doing this, instead of implementing a
struct that needs to be carry out with the data just create a class that
implement IComparer. Then you can use Array.Sort with this IComparer.
This is how it will looks:
public class NumberingSorter: IComparer
{
public int Compare(object x, object y)
{
if ( (x== null ) && (y==null) )
return 0;
if ( x == null )
return -1;
if ( y == null )
return 1;
// convert to string
string x1 = x.ToString();
string y1 = y.ToString();
//now split the str
string[] partsX = x1.Split( new char[] { '.' } );
string[] partsY = y1.Split( new char[] { '.' } );
//You should put this on a cycle !!!
if ( partsX[0] > partsY[0] )
return 1;
if ( partsX[0] < partsY[0] )
return -1;
// If they are equal pass to the next one
}
}
Please note that I adapted the above code from another class with a similar
functionality and you will have to refine it, the logic is there though.
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Morten Wennevik" <EMail@HideDomain.com> wrote in message
news:EMail@HideDomain.com...
> Hi Dave,
>
> You could create a struct out of a single string for the text and have the
struct implement IComparable. Putting the structs inside any list with a
Sort method should sort it according to your needs.
>
> The CompareTo method will be called on each object to determine if it is
"larger" or "smaller" or "equal" to some other object.
>
> ArrayList list = new ArrayList();
>
> RequirementNumber r = new RequirementNumber();
> r.Number = "1.1";
> list.Add(r);
>
> r = new RequirementNumber();
> r.Number = "1.10";
> list.Add(r);
>
> r = new RequirementNumber();
> r.Number = "1.2";
> list.Add(r);
>
> r = new RequirementNumber();
> r.Number = "1.1.1";
> list.Add(r);
>
> list.Sort();
>
>
> The list will now be
>
> 1.1
> 1.1.1
> 1.2
> 1.10
>
> If this is not the way you want it sorted, just changed the code to what
you need.
>
> public struct RequirementNumber : IComparable
> {
> public string Number;
>
> public int CompareTo(object o) // this method will be called by Sort()
> {
> if(!(o is RequirementNumber))
> return -1;
>
> RequirementNumber temp = (RequirementNumber)o;
>
> string[] local = Number.Split(new char[]{'.'});
> string[] remote = temp.Number.Split(new char[]{'.'});
>
> int[] numlocal = new int[local.Length];
> int[] numremote = new int[remote.Length];
>
> for(int i = 0; i < local.Length; i++)
> {
> string s = (string)local[i];
> try
> {
> numlocal[i] = Int32.Parse(s);
> }
> catch
> {
> numlocal[i] = 0;
> }
> }
>
> for(int i = 0; i < remote.Length; i++)
> {
> string s = (string)remote[i];
> try
> {
> numremote[i] = Int32.Parse(s);
> }
> catch
> {
> numremote[i] = 0;
> }
> }
>
> for(int i = 0; i < numlocal.Length; i++)
> {
> if(numlocal[i] < numremote[i]) // X.1.X < X.2.X
> return -1;
> else if(numlocal[i] > numremote[i]) // >
> return 1;
> // else equal and we need to check the next step
> if(i == numremote.Length -1) // X.X > X.X.X
> return 1;
> }
>
> if(numremote.Length > numlocal.Length) // X.X.X < X.X
> return -1;
>
> return 0; // numbers are equal
> }
> }
>
>
> Happy coding!
> Morten Wennevik [C# MVP]
|
| |
|
| |
 |
Morten

|
Posted: Thu Jun 03 08:48:51 CDT 2004 |
Top |
Visual C#.Net >> Order Text as Numbers
Yes Ignacio, Array.Sort with IComparer is probably far better. You learn something every day :)
In this case, drop the struct, make a new class and use an instance of the class to sort an array of strings.
string[] test = new string[]{"1.1", "1.10", "1.2", "1.1.1"};
SortClass sc = new SortClass();
Array.Sort(test, 0, test.Length, sc);
This should sort the strings in the same way as my other example.
public class SortClass : IComparer
{
public int Compare(object x, object y)
{
if(!(x is String) || !(y is string))
return -1;
string X = (string)x;
string Y = (string)y;
string[] local = X.Split(new char[]{'.'});
string[] remote = Y.Split(new char[]{'.'});
int[] numlocal = new int[local.Length];
int[] numremote = new int[remote.Length];
for(int i = 0; i < local.Length; i++)
{
string s = (string)local[i];
try
{
numlocal[i] = Int32.Parse(s);
}
catch
{
numlocal[i] = 0;
}
}
for(int i = 0; i < remote.Length; i++)
{
string s = (string)remote[i];
try
{
numremote[i] = Int32.Parse(s);
}
catch
{
numremote[i] = 0;
}
}
for(int i = 0; i < numlocal.Length; i++)
{
if(numlocal[i] < numremote[i]) // X.1.X < X.2.X
return -1;
else if(numlocal[i] > numremote[i]) // >
return 1;
// else equal and we need to check the next step
if(i == numremote.Length -1) // X.X > X.X.X
return 1;
}
if(numremote.Length > numlocal.Length) // X.X.X < X.X
return -1;
return 0; // numbers are equal
}
}
Happy coding!
Morten Wennevik [C# MVP]
|
| |
|
| |
 |
dave

|
Posted: Fri Jun 04 02:59:19 CDT 2004 |
Top |
Visual C#.Net >> Order Text as Numbers
Thanks very much for all your help everyone. It seems there are some
great answers which I can have a bash at.
Thanks again
Dave
|
| |
|
| |
 |
| |
 |
Index ‹ DotNet ‹ Visual C#.Net |
- Next
- 1
- Dotnet >> Parameter replacement wizard using code templates in Visual Studio 2005Hey all , I wanted to create a project or item template in C# such
that when I use that template a parameter wizard comes up asking for
values. I know how to create the template without implementing the
wizard, i.e., work the parameter replacement using the
<CustomParameters> keyword in XML.
So any hints or suggestions towards the procedure to having the
parameter replacement wizard (a GUI of some sort) would be greatly
appreciated,
cheers
- 2
- Winforms >> Acceptbutton does not work in usercontrols.If you have buttons on a form and you tab around when a button gets focus it
automatically gets highlighted. That is the forms AcceptButton changes to
the currently focused button. However when you have a usercontrol with a few
buttons in it and you tab around in there when the button gets focus it does
not automatically get highligthed. You can press Spacebar to activate but
that is not desired behaviour. Dont want to handle leave and enter events on
all buttons just because they are in a usercontrol to get them highlighted.
How can this be achieved?
Best Regards
//P
- 3
- ADO >> Dataadapter Add vs UpdateI have a generic question regarding ADO.net and how the CommandBuilder works.
I have a datagrid/dataset that is partially populated from pre exisiting records in a database table as well as NEW records/rows which are being added to the same dataset by a user via a simple textbox/form.
My question is, when the user is done adding new records and hits the final UPDATE button, does the dataadapter automatically know which records in my dataset are UPDATE preexisiting records as well as ADD new records (added manually by the user/form) or do I need to somehow programmatically , iterate through each row of the dataset, determine which rows are ADDS and which rows are UPDATES and then assign the appropriate SQL Sub Call (or if then) to each row in order to update the database table.
Thanks
devon
- 4
- ADO >> Create DataTable From Existing DataTablei created a SataSet that contain several DataTables,
i need to create some more DataTables and DataVies,
the problem is that each of them should contain another
DataColumns, i eant to select the columns from the
existing tables not only the rows.
sample:
one of the datatables in the dataset contain those
DataColumns: firstName, lastName, address,phone,fax and
mobile,
i want to create DataView that carry all the rows that the
last name begin with 'A' , but the columns needed are only
the last name and first name.
- 5
- ADO >> I don't understand pooling :-SOK, I understand what it's supposed to do, but I don't understand what it is
actually doing. Actually, I don't understand the .Net CLR Data values
numbers reported by Performance Monitor.
I wrote a very simple app that allows me to specifically open and close a
sql connection. When I open the connection, I see the Current # connection
pools increase by one and the Current # pooled connections increase by 2.
This is consistant with my understanding of what the pooling is supposed to
do. I can open and close the connection as many times as I like and the
numbers don't change.
When I close the app, the numbers in performance monitor remain the same. I
was expecting them to go away.
Then I run the app again. I open the connection and the previously mentioned
values increase again! Basically, it's like a whole new pool is created
again. What is going on? Is Performance Monitor misreporting or is the
pooling not working properly. Reading some of the messages here about this
subject, it appears that the latter would be true.
Even after I close VS, Performace Monitor continues to report the same
values. They don't go away.
--
Willy Esteban
- 6
- Visual C#.Net >> 0.00007m -> 7E-5 ?Hello.
I'd want to see the right value that inserted, but very small value like
0.00007m doesn't displayed exactly(displayed 7E-5).
ex)
decimal b = 0.00007m;
TextBox.Text = b.ToString(); => 7E-5
TextBox.Text = b.ToString("F"); => 0.00
TextBox.Text = b.ToString("0.00000"); => 0.00007 (but 0.00000007 not
supported)
TextBox.Text = b.ToString("0.0000000000"); => 0.0000700000
so, I want to know the string format type that all decimal values show the
values as it is.
decimal b = 0.00007m; ( for all decimal cases like 0.0000007m,
0.0000000000007m )
TextBox.Text = b.ToString(????); => 0.00007
Please, help me~ ^^
ps. maybe understanding this question is harder than solving..^^ sorry and
thanks..
- 7
- Microsoft Project >> mail mergeAlthough I am quite fluent in using Ms word I cant get my head around mail merge,
crewating an address list and print envelopes etc from that list. Please can anyone help thanks.
- 8
- ADO >> DDE command with sqlComman objectHi,
i try to execute a DDE command with an SQlClientSQLCommen object and i
obtain "syntax error near "Then" ":
dim sql as string
sql = "CREATE TRIGGER myTrigger " & _
"ON MyTable " & _
"AFTER(UPDATE) " & _
"AS " & _
"BEGIN " & _
"SET NOCOUNT ON; " & _
"If UPDATE(Myfield) Then " & _
"BEGIN " & _
"UPDATE MyTable SET MyOtherField=1 WHERE myID IN (SELECT myID from INSERTED)
" & _
"END " & _
"END"
dim oCmd as new sqlClient.SqlCommand(sql,MyConnection)
oCmd.CommandText = sql
oCmd.ExecuteNonQuery()
So, is my syntax incorrect ? (this request works well in a query analyzer)
Best regards,
--
Sebho
- 9
- 10
- Dotnet >> System.Messaging namespace missing in VB.NET?After spending a little time reading the documentation, I attempted to add
some messaging code to my VB.Net project, only to discover that I couldn't
get past my
Imports System.Messaging
statment because the System.Messaging namespace is missing. Did I fat
finger it into oblivion without knowing it, or is this a known issue? Any
suggestions on how to fix this, in any case?
Any help appreciated...
- 11
- 12
- ADO >> Data View Thread Safety ProblemI have a multi-threaded application with a static constructor and static
DataSet and DataView variables, populated in the constructor.
i then create many threads to access the static DataView but some of the
threads generate errors while others work. Here is the code for the sample
console app
using System;
using System.Data;
using System.Threading;
namespace DataViewTest
{
class DataViewTest
{
static DataSet _ds;
static DataView _dv;
private volatile Thread _thread;
private string _name;
static DataViewTest()
{
_ds = new DataSet();
DataTable tableOne = new DataTable("TableOne");
tableOne.Columns.Add(new DataColumn("Force", typeof (int)));
tableOne.Columns.Add(new DataColumn("Section", typeof (string)));
tableOne.Columns.Add(new DataColumn("ApplicationID", typeof (string)));
tableOne.Columns.Add(new DataColumn("GroupID", typeof (int)));
tableOne.Columns.Add(new DataColumn("Name", typeof (string)));
DataRow newRow = tableOne.NewRow();
newRow["Force"] = 13;
newRow["Section"] = "0";
newRow["ApplicationID"] = "FA";
newRow["GroupID"] = 1;
newRow["Name"] = "ZZ";
tableOne.Rows.Add(newRow);
_dv = new DataView(tableOne, null, "GroupID", DataViewRowState.CurrentRows);
_ds.Tables.Add(tableOne);
_ds.AcceptChanges();
}
public DataViewTest(string threadName)
{
_name = threadName;
}
internal void Run()
{
if(_dv[0]==null)
{
System.Diagnostics.Trace.WriteLine(string.Format("{0} FAILED", _name));
}
else
System.Diagnostics.Trace.WriteLine(string.Format("{0} worked", _name));
}
internal void Start()
{
_thread = new Thread(new ThreadStart(Run));
_thread.Name = _name;
_thread.IsBackground = true;
_thread.Start();
}
}
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
private static DataViewTest[] _workers;
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
_workers = new DataViewTest[100];
for (int ct=0; ct<_workers.Length; ct++)
{
_workers[ct] = new DataViewTest(string.Format("Thread '{0}'", ct));
}
for (int ct=0; ct<_workers.Length; ct++)
{
_workers[ct].Start();
}
while(true)
Thread.Sleep(1000);
}
}
}
here is some sample output
Thread '0' worked
The thread 'Thread '0'' (0x1dd4) has exited with code 0 (0x0).
Thread '27' worked
The thread 'Thread '27'' (0x1f18) has exited with code 0 (0x0).
Thread '63' worked
Thread '6' worked
Thread '1' FAILED
The thread 'Thread '6'' (0x1e70) has exited with code 0 (0x0).
The thread 'Thread '1'' (0x1b08) has exited with code 0 (0x0).
Thread '3' FAILED
The thread 'Thread '3'' (0x14d8) has exited with code 0 (0x0).
Thread '11' worked
Thread '2' FAILED
The thread 'Thread '11'' (0x1d90) has exited with code 0 (0x0).
The thread 'Thread '2'' (0x1bd8) has exited with code 0 (0x0).
Thread '5' worked
The documentation says that DataViews are threadsafe, so why is this
happening? Sometimes, everything is OK, but more often than not, at least one
thread fails.
- 13
- Visual C#.Net >> Parsing using RE?Hello all
I have a huge string that I need to parse
Key <Delim1> Value <Delim2> Key <Delim1> Value <Delim2> Key <Delim1>
Value <Delim3>
Key <Delim1> Value <Delim2> Key <Delim1> Value <Delim2> Key <Delim1>
Value <Delim3>
repeat for a couple hundred thousand times
The <Delim1> seprates the Key, Value pair
<Delim2> seprates two different Key,Value pairs
<Delim2> seprates records.
I need to get the Key Value pairs and populate a table with that
information.
Would the .NET regular expressions be worth while and how would I go
about doing it in a clean optimized fashion.
Thanks
-Ravi Singh
- 14
- Visual C#.Net >> Garbage CollectionHello:
We are considering developing a time critical system in C#. Our tool used in
Semiconductor production and we need to be able to take meaurements at
precise 10.0 ms intervals( 1000 measurement exactly 10 ms apart. In the
future this may decrease to 5ms ). I am concerned that if garbage
collection invokes during this time it may interfere with our measurement
results. I have looked over the garbage collection mechanism and see no way
to control when garbage collection occurs. Is there a way to pause and
start garbage collection? or some other technique that I can use to prevent
garbage collection while I am taking measurements?
Thanks
Bob
- 15
- ADO >> Regenerate datasetsHow do other "regenerate a dataset" and when that term is used, what does it
mean? Telling the designer to "generate" a dataset results in a NEW file,
which you then have to jerk around to fit into the old structure. An easier
way seems to be just to go into the designer and make changes. Example, I'm
making changes to the underlying database. So I go into the .xsd and delete
the old table structure and add the new table structure (and relations). Is
there any other way?
|
|
|