|
Sweet, thanks for the quick replys.
Arun
My application that uses the third party tool is not multithreaded.
Daniel
Yeah, I saw that in the task manager, that's what led me to believing that the multi cpu was the problem because when I did set the affinity to just one cpu it works great.
parths
Sweet, I'll have to try that out and see if I can limit it using that call.
UPDATE:
I tried that SetProcessAffinityMask method and it worked like a charm. I added what I did to the www.pinvoke.net/[^] collection. Love that site. Thanks for you help.
|
|
|
|
|
I'm in a somewhat sticky situation.
I'm developing an Explorer Bar (for IE). In my implementation, I used a few singletons for very important (core) classes which are, by design, singleton. I guess I didn't want to have to manage parent-child relations for conceivably every object I worked with, but it seems like that was a bad decision. This worked okay until I realized that new windows in IE (such as created by Ctrl-N or File->New Window) are running in the same process, and since the singleton pattern I'm using does so with a static accessor (get) property, this system fails as I believe the two instances of the Explorer Bar are running in the same AppDomain because they're running in two different threads of the same IE process. So basically, instead of having separate singletons per thread group, then end up sharing the same singleton, which is bad for Windows Forms objects.
The kinda tricky thing is that my Explorer Bar is multi-threaded, so I can't just implement my singleton accessor using a hashtable keyed on the thread ID. If there were a way to access a thread group ID, or some sort of way to figure out which thread ID or IE window owns that particular CLR instance, that would be helpful.
So any suggestions, managed or unmanaged, would be helpful. Maybe I simply need to rearchitect everything, even though now really isn't the best time for that. I'd rather be able to add a few lines into my singleton accessor (Singleton.Instance) instead.
Thanks!
Arun
|
|
|
|
|
Hello
I have an object. This object contains an enum value, but I do not know which type the value is. I can find out by asking GetType.
The problem is that the object can contain different kinds of enums. All these enums inherit from int, and I want to know the value of this int.
How do I get the value of an object, when I know that the object contains an enum value of type GetType?
Programically(pseudo code), it can be written like:
intGetIntFromEnum(Type type, string enumString)
{
object enumObject = Enum.Parse(type, enumString);
return (int)enumObject; // Here it fails..., even though the enumobject's type is inheriting from int
}
Gooky
|
|
|
|
|
That should work! I use very similar code in a custom XML serializer/deserializer I wrote. This also works:
<br />
MessageBox.Show(((int)Enum.Parse(typeof(AnchorStyles), "Left")).ToString());<br />
It displays "4". Maybe enumObject is returning null , perhaps because the enumString is incorrect?
|
|
|
|
|
Hehe..
Playing a little around....
System.Convert.ToInt32(enumObject) works perfect. Thanks anyway
Gooky
|
|
|
|
|
Hi,
Someone responded to my post before, about how to keep the scroll bar at the bottom of a text field... I didn't understand the code ONE bit, and I am used to vb, with the simple Text1.SelText(Text1) type deal... is there a similar method within c#? i scanned MSN docs to find nothing -_- please help!!!!
|
|
|
|
|
How about the following:
string str = "Nick Parker";
text1.Test = str;
string search = "Nick";
int index = str.IndexOf(search, 0, 0);
if(index != -1)
{
text1.Select(index, search.Length);
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
A new version of wx.NET was recently released. wx.NET provides .NET bindings for wxWidgets, a powerful cross-platform GUI toolkit. wx.NET/wx.Widgets uses the native UI framework on each supported platform: Windows, Linux, and Mac OS X.
The new 0.5 version has many improvements over previous releases. A quick summary of changes:
- Dozens of new classes.
- Full support for Mac OS X.
- New event system: Activated, Closing, MouseEnter, etc. events.
- Easier to use binary downloads for Windows, Linux, and Mac OS X.
- An new build system to make compiling easier along with a user manual to step you through the process.
- 6 new samples and an easy to use sample launcher.
- A new tool to generate C# or VB.NET code from XRC or wxGlade WXG UI layout files. Supports editing of the resulting code and
modifications to the UI similar to the VS.NET System.Windows.Forms designer. - CLS compliant (no more uints).
- Numerous bug fixes.
Key contributors to this release:
- Alexander Olk
- Bryan Bulten
- Mike Muegel
Wx.NET is completely open source and free. More information is available at:
http://wxnet.sf.net/
We have recently started a fundraising campaign to support the work of Alexander Olk on the project. Please see the following for details:
http://wxnet.sf.net/donate.html
Even a little bit will help accelerate development. I've jump started the fund by donating US$150.
Best Regards,
-Mike Muegel on behalf of the wx.NET Development Team
|
|
|
|
|
Mike, due to the large number of threads within the C# forum, you may consider writing an article about using wx.NET and posting it here on CP, otherwise this thread will soon become lost. Good luck.
- Nick Parker My Blog | My Articles
|
|
|
|
|
I'm using Late binding to control powerpoint. I now am at the point where
it does what I want it to do, but I need some eventhandling to know what it's doing.
All the samples I see that deal with events use early binding
(http://support.microsoft.com/default.aspx?scid=kb;en-us;308825)
and this type of function:
<br />
oPPT = new PowerPoint.ApplicationClass();<br />
UCOMIConnectionPointContainer oConnPointContainer = (UCOMIConnectionPointContainer) oPPT;<br />
Since I'm using LateBinding, i Use:
<br />
Object oPPT;<br />
Type objClassType;<br />
objClassType = Type.GetTypeFromProgID("Powerpoint.Application");<br />
oPPT = Activator.CreateInstance(objClassType);<br />
Now when trying to do the same thing with UCOMIConnectionPointContainer it returns NULL because it's just an 'object' due to late binding - How do i fix this?
How can I hook up events when using late binding? Is this even possible?
Thanks
|
|
|
|
|
I have a datagrid that all of its columns are BoolColumnStyle and its DataSource is a table with no relations. I relate this DG with a counter, when I mark true or false in each DataGridCell the counter adds or subtracts (respectively) a certain number. Also I relate a TreeView with this DataGrid that the previous counter works separately for each TreeNode under the TopNode in this DataGrid. I used the following code to make my datagrid to respond to one click :
private void dataGrid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
DataGrid.HitTestInfo hti = this.dataGrid1.HitTest(e.X, e.Y);
try
{
if( hti.Type = = DataGrid.HitTestType.Cell )
{
int r = (int)hti.Row;
int c = (int)hti.Column;
DataRow dr = table.Rows[r];
DataColumn dc = table.Columns[c];
this.dataGrid1[r,c] = !(bool) this.dataGrid1[r,c];
}
}
catch(Exception ex )
{
MessageBox.Show(ex.ToString());
}
} I have the following problems :
1. The following message appears. I do not know what is the ListManeger or in other words, I do not understand what is the problem.
The ListManeger’s position must be equal to the rowNum.
Parameter name: rowNum Do you want to correct the value? 2. The DataGrid responds to clicks even when there is no any TreeNodes are selected although I make a ckeck if (TreeView.TreeNode IsSelected). I want the DataGrid to respond to clicks only when any TreeNode under the TopNode is selected.
3. when the selected TreeNode is changed, I empty the DataGrid by the following code, but the last cell that I add a value to it remains checked :
for(int i=0 ; i<table.Rows.Count ; i++)
{
DataRow dr = table.Rows[i];
for(int j=0 ; j<table.Columns.Count; j++)
{
dr[j] = false;
}
} The problems 1 and 3 disturb my counter.
Please if there is a solution.
Thank you
|
|
|
|
|
Let's say that I am having two Dataset objects ds1 and ds2. These DataSets have exactly the same schema. Same DataTable (only one) in each DataSet and same DataColumns. Can anyone tell me, how can I join these two DataSets into a third one, so that the new one will have the DataRows of ds1.Tables[0] followed by the DataRows of ds2.Tables[0]?
.::YF::.
|
|
|
|
|
Let's say that I am having two Dataset objects ds1 and ds2. These DataSets have exactly the same schema. Same DataTable (only one) in each DataSet and same DataColumns. Can anyone tell me, how can I join these two DataSets into a third one, so that the new one will have the DataRows of ds1.Tables[0] followed by the DataRows of ds2.Tables[0]?
The language I am writing the project is C#.
.::YF::.
|
|
|
|
|
Try to create a function to join them... Maybe this that join tables can help you
public static DataTable JoinDataTable(DataTable odtt1, DataTable odtt2)
{
DataTable odtt = odtt1.Copy();
foreach(DataRow row in odtt2.Rows)
{
try
{
DataRow r = odtt.NewRow();
r.ItemArray = row.ItemArray;
odtt.Rows.Add(r);
}
catch(Exception e) //if the schema are not equal
{
string x = e.Message;
break;
}
}
return odtt;
}
Just do
DataSet ds3 = new DataSet();
ds3.Tables.Add(JoinDataTable(ds1.Tables[0],ds2.Tables[0]));
maybe it works... good luck
Wender Oliveira
.NET Programmer
|
|
|
|
|
Hi,
This is probably a really dumb question, but I haven't done many C# Windows apps - I've been living in the web world. What's the usual way of defining some standard sets of fonts/size/colors for all the labels of a windows app? I'll have many labels of 3 basic 'styles' and I don't want to go and set the font size on each of them. I'd rather declare the 3 'styles' and attach the labels to them.
thanks,
Deanna
|
|
|
|
|
There's not really something like css for Windows Forms built-in.
Unless overriden, a control adapts to it's container's properties (for example, dropping a label onto a form will give it the font, fore- and backcolor of the form), but that's not really what you want.
I think you'll have to invent something on your own...
You could derive a LabelWithStyle from Label, though. This label could receive an additional Style property and look up fonts, colors etc. from an embedded resource.
Regards,
mav
|
|
|
|
|
Hi.
I creat this property:
private byte[] m_buf;<br />
public byte[] Buffer<br />
{<br />
get{return m_buf;}<br />
set{m_buf=value;}<br />
} when i bind this property to Image type in sql server, at run time displaying this error:
cannot convert system.DBNull to other type.
please help me.
|
|
|
|
|
Hi!
I am developing a client/server app.
The problem is that the server side is uneable to read from the cryptostream (although the underlying NetworkStream has available data).
Here's the client side:
tcpc=new TcpClient();
tcpc.Connect(Client.Settings.serverName,Client.Settings.ServerRegisterPort);
NetworkStream S=tcpc.GetStream();
BinaryFormatter bf=new BinaryFormatter();
CryptoStream Si, So;
Client.DoKeyExchange(S,out Si,out So);
string resp="OK\n";
byte b=3;
So.WriteByte(b);
So.Flush();So.FlushFinalBlock();
S.Flush();
And the server side:
NetworkStream S=new NetworkStream(Soc,true);
BinaryFormatter bf=new BinaryFormatter();
CryptoStream Si,So;
Server.GetKeyExchange(S,out Si,out So);
b=Si.ReadByte();
The server block (maybe waiting for more data) at this line.
And the two functions:
public static void DoKeyExchange(Stream S, out CryptoStream Si, out CryptoStream So)
{
Rijndael rijn=Rijndael.Create();
//rijn.KeySize=128;
rijn.GenerateIV();
rijn.GenerateKey();
RSAOAEPKeyExchangeFormatter RsaF=new RSAOAEPKeyExchangeFormatter(rsa);
byte [] iv=RsaF.CreateKeyExchange(rijn.IV);
byte [] key=RsaF.CreateKeyExchange(rijn.Key);
BinaryFormatter bf=new BinaryFormatter();
bf.Serialize(S,iv);
bf.Serialize(S,key);
S.Flush();
rijn.Key=ASCIIEncoding.ASCII.GetBytes("ABCDEFGHABCDEFGH");
rijn.IV=ASCIIEncoding.ASCII.GetBytes("ABCDEFGHABCDEFGH");
So=new CryptoStream(S,rijn.CreateEncryptor(),CryptoStreamMode.Write);
Si=new CryptoStream(S,rijn.CreateDecryptor(),CryptoStreamMode.Read);
}
public static void GetKeyExchange(Stream S, out CryptoStream Si, out CryptoStream So)
{
RSAOAEPKeyExchangeDeformatter RsaF=new RSAOAEPKeyExchangeDeformatter(rsa);
BinaryFormatter bf=new BinaryFormatter();
byte [] iv=(byte[])bf.Deserialize(S);
byte [] key=(byte[])bf.Deserialize(S);
iv=RsaF.DecryptKeyExchange(iv);
key=RsaF.DecryptKeyExchange(key);
Rijndael rij=Rijndael.Create();
rij.IV=iv;
rij.Key=key;
Si=new CryptoStream(S,rij.CreateDecryptor(key,iv),CryptoStreamMode.Read);
So=new CryptoStream(S,rij.CreateEncryptor(key,iv),CryptoStreamMode.Write);
}
Any ideeas?
Best,
Mircea
|
|
|
|
|
Hi, all the time is showing me error at line:
objConexao = New SqlConnection(connString);
which says that I forgot the semicolon(;), but as you can see I did not forget it!
See the whole routine bellow inside a .aspx page:
<%@ Page Language="C#" Debug="true"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script language="C#" runat="server">
public void Page_Load(Object Sender, EventArgs EA)
{
String connString,strSQL;
SqlConnection objConexao;
SqlCommand objCommand;
SqlDataReader objDataReader;
connString = "Server=Localhost; Database=Northwind; Uid=SqlService; Password=xx;";
objConexao = New SqlConnection(connString);
objConexao.Open();
strSQL = "SELECT * FROM Products";
objCommand = New SqlCommand(strSQL, objConexao);
objDataReader = objCommand.ExecuteReader(CommandBehavior.CloseConnection);
While(objDataReader.Read = True)
{
lblSaida.Text += objDataReader["ProductName"] + " - " + objDataReader["UnitPrice"] + "<br>";
}
objDataReader.Close();
objConexao.Close();
objDataReader = Nothing;
objCommand = Nothing;
objConexao = Nothing;
}
</script>
-------------
Thanks,
=========================
Vilmar Brazão de Oliveira
|
|
|
|
|
This question belongs in the ASP.NET[^] forum. However just a side note, that message is typically a sign that you left something out above where it ran into your code statement saying you need a semicolon.
- Nick Parker My Blog | My Articles
|
|
|
|
|
OK, so how can I fix it?
thanks by help.
=========================
Vilmar Brazão de Oliveira
|
|
|
|
|
Take care... you're mixing VB and C#... C# is case sensitive so make your line objConexao = New SqlConnection(connString); to have a lowercase new like objConexao = new SqlConnection(connString);
don't forget that Nothing doesn't exists... use null like
objDataReader = null;
But I think that you won't need to set null or nothing to your objects because your already have the Garbage Colector
Good Luck and abraços!
Wender Oliveira
.NET Programmer
|
|
|
|
|
Hey guys,
I thank you all!
Wender you guessed! My problem is that I am more habituated with VB/VB.net than with C#.
Regards,
Um abraço tb.!
=========================
Vilmar Brazão de Oliveira
|
|
|
|
|
How can I get an XmlNode from an XmlTextReader . What I really want to know is this.
Here is my XmlTextReader
XmlTextReader xtr=new XmlTextReader(this.textBox1.Text);
Now, I want to use this method, but I can't get an XmlNode out of xtr. What do I do?
public void LoopThroughChildren(XmlNode root)
{
this.listBox1.Items.Add(root.Name+ " \t\t\t"+root.FirstChild.Value);
foreach (XmlNode n in root.ChildNodes)
{
if (n.NodeType == XmlNodeType.Element)
{
LoopThroughChildren(n);
}
}
}
I was using an XmlDocument but my xml file is too large to use it anymore... So basicilly can somebody help me write a recursive method that goes though an entire xml file?
/\ |_ E X E GG
|
|
|
|
|
Nevermind, I just realized how dumb my question was...
/\ |_ E X E GG
|
|
|
|
|