|
private void HomeFrom_Activated(object sender, System.EventArgs e)<br />
{<br />
<br />
<br />
PrimeInfoThread pTh = new PrimeInfoThread(this.pictureBox1,this.panel4,this.button1,this.button3,this.SLabel);<br />
Thread t = new Thread(new ThreadStart(pTh.ThreadProc));<br />
t.Start(); <br />
<br />
}<br />
<br />
...<br />
public class PrimeInfoThread<br />
{<br />
private System.Windows.Forms.PictureBox hPic ;<br />
private System.Windows.Forms.Panel hPan ;<br />
private System.Windows.Forms.Button but1 ;<br />
private System.Windows.Forms.Button but2 ;<br />
private System.Windows.Forms.Label slab ;<br />
<br />
public PrimeInfoThread(System.Windows.Forms.PictureBox hP,<br />
System.Windows.Forms.Panel hpanel,<br />
System.Windows.Forms.Button b1,<br />
System.Windows.Forms.Button b2,<br />
System.Windows.Forms.Label Sl) <br />
{<br />
hPic = hP;<br />
hPan = hpanel;<br />
but1 = b1;<br />
but2 = b2;<br />
slab = Sl;<br />
}<br />
<br />
public void ThreadProc() <br />
{<br />
EnumGetEDID InitEnumObj = new EnumGetEDID();<br />
InitEnumObj.AppInitEnum(slab); <br />
hPic.Hide();<br />
hPan.Hide();<br />
but1.Show();<br />
but2.Show();<br />
<br />
}<br />
<br />
}<br />
I have the above code where I modify my form controls in another thread.
Is is safe to do like this. How to do this using thread-safe calls/delegates.
Thanks.
|
|
|
|
|
Take a look at this[^] article on BeginInvoke
Hope this helps
Cheers,
Will H
|
|
|
|
|
Consider using class Monitor
|
|
|
|
|
How do I place the error icon on a custom form?
|
|
|
|
|
Not sure if this is what you're after, but you can get the standard error icon using the System.Drawing.SystemIcons.Error property. You could then draw this onto your custom form during its OnPaint method, or using a PictureBox (although this will probably render badly - removing the icons alpha channel - so your best bet is to draw it manually in OnPaint ).
Hope this helps
Cheers,
Will H
|
|
|
|
|
Thanks so much, Will. You're right - using .Image of the PictureBox looks rough. The OnPaint looks better.
|
|
|
|
|
Hi all,
i need to make 2 deployment packages with some limitations.
1. VS.Net Express :
I have only 1 EXE file (remind you its FW 2.0) but i want to make it
automaticly download the needed packages like Framework2 or windows
installer if from some reason it is needed.
basicly i can give only the EXE and thats it but if the user dont have the
framework its a problem , i can not send him menualy to the site.
i also dont need to install my program or unistall later, just install the
framework 2.0 and run my program(dont want icons too)
so what can i do here?
2. VS.Net Express too:
this one have EXE and WAVS + readme..etc.
and i want to make Installation to start menu (no desktop no quick launch)
and also uninstall..
if this package do not check and download the framework 2.0 , it will be ok
but if it is posible - that would be great.
P.S: the reason i use VS Express is because i have licnece for it, otherwise my problems would be over , i would have used the deployment projects.
Please help i have no idea what to do.
Thanks alot people,
Ran.
R.Z
|
|
|
|
|
Private Sub Socket_ConnectEvent(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Socket.ConnectEvent<br />
Dim Index As Short = Socket.GetIndex(eventSender)<br />
Socket(Index).SendData(Data(ClientID(Index)))<br />
End Sub
The Code above i'm trying to convert into C# I'm having a pretty tough time at it,I have this in my Constructor::
socket.ConnectEvent += new EventHandler(Socket_ConnectEvent);
in the Body i did have short index = Socket.GetIndex(eventSender)
|
|
|
|
|
I want to be able to start an app the 1st time the user clicks a button, with the 2nd and subsequent calls simply giving focus to the already running instance. Since there's no Focus method, how would I go about doing this?
|
|
|
|
|
Hello,
I have implemented a webservice by using websphere. an c# client calls this service successfull, however it always gives a timeout in the second call. The first, third, fourth call etc.. are alway successfull but the second fails all the time (timeout). Monitoring the servlet on the websphere side shows that there is no incoming traffic from the second c# call.
I tried both ways (synchrone-call and the asynchronious variant) but the second call always causes a time-out.
the .jsp testpage (generated by the websphere environment) works fine all the time, so the suspecion points to c#
who has an idea what can cause the trouble.
thanks in advance
leon van rooijen
|
|
|
|
|
I've created an application that uses panels with images as background having a pretty good looking application at the place of the normal windows xp style...
But when i resize it, or i wait to see it ended to load on start, or in all the other time that it is called on paint event, i see flicker the panels that uses images as background.
Sometime i see it all black before fully end to draw the image or i see just the border.
Why? How can i avoid it? (i use double buffer too)
|
|
|
|
|
Ok, I have the following problem. A function is called asyncronously in the program, and someone told me that is done in a new Thread. Inside the function I want to open a new form but it crashes when I try. So i decided I have to open the form in the main thread. Can anyone please tell me how can I do just that? Thank you.
|
|
|
|
|
Use Form.Invoke to call a control method outside the thread where it was created. You have to know how to work with delegates to do that.
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
Thank you verry much
|
|
|
|
|
|
If you include the reference to Word in the project, all your project will generate is an interop file for Word. You won't need a license for that. To be able to use Word on a target installation machine, the machine must have Word already installed. So I don't think you will have any licencing issue. Also, I don't think your operations on Word (in the application) will work if the target machine does not have MS Word already installed.
There has to be more to life than just this
|
|
|
|
|
Hello every one
After 2 hard week of work, finally i accomplished an reliable server and client classes which look like the VB Winsock, those 2 classes are reliable, also server enable multiple connections, as i test it accept 5000 connection and Handel them,
When i try to create an demo app. on these 2 powerful classes, all goes fine, i faced an problem in sending files, as I'm using one channel only between server and client, i.e. each client have only one channel, this channel Handel both data and commands, we can distinguished between them, that command will always contain [#<cmd>#] tag before the command itself, so in the OnDataReceived event, we convert the byte array to ASCII string to search inside it, if we find the prev. tag then this a command else we just use that array to put on file or something, the logic is tested before on my prev. vb6 app.
Here an scenario of connection,
1- Client connected to server, server add its info to listview,
2- Server request from client to capture desktop screen
3- Client receive the command and capture the image convert it to JPEG, and then add to that array the following tag at the end of array [#<eof>#], which help us to detect the end of file.
4- Client tell the server that it ready to send, given to server the length of image array without the length of tag,
5- When server receive readytosend, it the client socket info to helper class which contain the socket id, image size, and memory stream, which contain image chunks,
6- then Server send the client an message ready to receive, in this moment client start sending data chunks in order of 1024 Byte per time,
7- Every time server receive data it check if its EOF or not, if its, remove the EOF tag, and all nulls, and write the last chunk to the image,
The problem is the image in coming deformed, also some times length of incoming data become greater than length saved from client in early steps, i.e. an **** on line collected while getting data,
After hard work, i try to put an execution delayer, using Thread.Sleep(0), and the surprise that its finally work, and the image size is correctly, and image is nice, But all this in LAN, when test app on Wan all goes bad again, i think the problem not the delay, but delay here prevent some bad thing to happen, i want to know why server put extra data on the image stream, from where these extra data come, Am I Missing Something.?!?!?!??!?!?!?
All i need, Any one test this code, its amazing, very exciting and commented, will learn you a lot, all i need is to detect the reason of that bugs,
To know what I'm talking about, In the server side in the OnDataReceived even, try to comment the Thread.Sleep(0); and try to get an image, you will got ****, if you put that line again all goes fine, and if you put it, and test it on Wan it will cause problems again, So there is something wrong, and i don't know it
Please any body help me finding that error.
Here is the link of the code, its written using C# 2005, Right click and choose Save Target As...
http://www40.brinkster.com/dominatorlegend/Network_Spy.rar[^]
Thanks every one and hope i explain the problem well, and hope for fast response.
Thanks in advanced for whatever help.
-- modified at 6:41 Wednesday 1st February, 2006
|
|
|
|
|
Ok, trying to loop through a treeview and create connection to each node(pc).
Am running a new thread to do this loop as it is taxing on the application.
PcTree = new Thread(new ThreadStart(enumThread));
PcTree.Name = "PollPCList";
PcTree.Start();
When I look at the output of my node looping I consitently find 3 connections to each node. After trying to step thru the debugger i find that sometimes it does keep this pattern(3 connections), other times i only see one loop for each node. (how odd is that?) -- why is this happening? is it due to the fact that i'm running this on a dual-proc pc?
now, that obviously is the problem, here is my question:
if i haven't done something wrong with my code and i'm stuck with this 'triple threat thread' then is it possible that i increment the foreach loop so that i process 3 different nodes instead of just one node 3 times?
private void enumThread()
{
enumPCtree(PCmonitorTree.Nodes);
}
private void enumPCtree(TreeNodeCollection t)
{
try
{
foreach ( TreeNode tr in t)
{
if (tr.Text.IndexOf("PC")!= -1)
{
tr.Nodes.Equals(tr.NextNode);
}
else
{
ServerName = tr.Text;
try
{
HostIP = System.Net.Dns.GetHostByName(ServerName);
PcIpAddress = HostIP.AddressList[0].ToString();
}
catch
{}
finally
{enumPCtree(tr.Nodes);}
if (PcIpAddress != null)
{
if (breakLoop)
{
break;
}
}
}
}
}
catch (Exception ex)
{MessageBox.Show(ex.Message);}
finally
{
}
}
string Beautiful;
Beautiful = "ignorant";
label1.Text = "The world is full of " + Beautiful +" people.";
Why is common sense such an un-common comodity?
|
|
|
|
|
How and where does this process get started? Is it within an event? Is that event getting called multiple times?
wetrivrrat wrote: it due to the fact that i'm running this on a dual-proc pc?
errmm...I'd have to say no.
|
|
|
|
|
I have a number of custom forms and controls that rely on runtime information to do their job. In cases where these items do their setup in the constructor, bad things happen when one of these is displayed in the designer.
Currently, I use the following code to determine if my item is running in the designer:
<br />
public static bool InDesignMode()<br />
{<br />
string exe = Application.ExecutablePath;<br />
if ( exe.IndexOf("devenv.exe") != -1 )<br />
{<br />
return true;<br />
}<br />
return false;<br />
}<br />
Although this works I’m wondering if there is a better way. I don’t like relying on something like a file name to make this kind of decision.
Any ideas or comments?
Thanks!
Chris
|
|
|
|
|
public class Utilities<br />
{<br />
private static bool AppRunnning = false; <br />
public static void Main(string[] args)<br />
{<br />
AppRunnning = true;<br />
Application.Run(new Form1());<br />
}<br />
public static bool InDesignMode<br />
{<br />
get { return !AppRunnning; }<br />
}<br />
}<br />
<br />
public class MyControl:UserControl<br />
{<br />
public MyControl()<br />
{<br />
if (Utilities.InDesignMode)<br />
{<br />
}<br />
else<br />
{<br />
}<br />
}<br />
}
|
|
|
|
|
Thanks!
A much cleaner solution that what I was using.
-Chris
|
|
|
|
|
You could try the Component.DesignMode property (MSDN[^])
Cheers,
Will H
|
|
|
|
|
Thanks... didnt know such existed!
- Malhar
|
|
|
|
|
One of my dialogs is behaving as though the alt key is always pressed. Typing the letter of any of the shortcuts for a button triggers the button regardless of which control currently has focus. None of the other dialogs in my app behave this way, and flicking back and forth between the affected dialog and the remainder's property pages I'm not seeing any relavant seeming differences.
|
|
|
|
|