|
Thanks guys,
A lot of good info there.. ive decided im going to buy a book on GDI+ as it looks very interesting..
Another question,
im having a lot of trouble in c# trying to copy a folder to a new locaton along with all its files and subdirectories. I can move it no problem but not copy it..
Any hints or guidance?
(I like to work the whole solutions out myself, using just hints if needs be)
|
|
|
|
|
My app was never designed to support threading - The GUI has a VB6 front end but I have rewritten it in VB.NET with a C# backend - don't ask
Some of the operations in the C# back end can take a long time are thus good candidates for running on a worker thread - these operations communicate back to the GUI using events - status information, adding rows to a datagrid, progress bar etc.
As I am new to threads in .NET can I still use the events from the function running on the worker thread but just change the event sinks so they use BeginInvoke to update the GUI controls?
The class which contains the long running operations has some database code in it - can I call that code from the long running operation on the new thread just as I would if it wasn't running on the thread? I don't believe I have any synchronisation issues as the database is always read only - the only reason I want the long running operation to run on a separate thread is so the GUI remains responsive, I dont actually intend to let the user do anything with the GUI other than maybe cancel the long running operation.
TIA
|
|
|
|
|
Sorry, posted it twice - the first attempt too 20 minutes then went blank - when I looked it wasn't there so I reposted it - naturally the first one decided to appear in the meantime
Rugby League: The Greatest Game Of All.
|
|
|
|
|
|
Thanks, I have read those articles and also in his book on Windows Forms programming where the articles are repeated. They don't really address my events question though.
|
|
|
|
|
Yes, you can still use evens. The article details exactly how to do it in terms of your GUI. First, subscribe to the events or use a delegate which points to your GUI's method. Either way will work fine. Your thread will call it's delegate or raise its event, and the UI thread will receive the notification.
In your gui you'll need code similar to this to handle the event:
private delegate void uiThreadDelegate(object sender, EventArgs e);
protected void MyEventHandler(object sender, EventArgs e)
{
if(this.InvokeRequired)
{
uiThreadDelegate ui = new ThreadDelegate(MyEventHandler);
this.BeginInvoke(ui, new object[]{sender, e});
}else{
... your code
}
}
|
|
|
|
|
My app was never designed to support threading - The GUI has a VB6 front end but I have rewritten it in VB.NET with a C# backend - don't ask
Some of the operations in the C# back end can take a long time are thus good candidates for running on a worker thread - these operations communicate back to the GUI using events - status information, adding rows to a datagrid, progress bar etc.
As I am new to threads in .NET can I still use the events from the function running on the worker thread but just change the event sinks so they use BeginInvoke to update the GUI controls?
The class which contains the long running operations has some database code in it - can I call that code from the long running operation on the new thread just as I would if it wasn't running on the thread? I don't believe I have any synchronisation issues as the database is always read only - the only reason I want the long running operation to run on a separate thread is so the GUI remains responsive, I dont actually intend to let the user do anything with the GUI other than maybe cancel the long running operation.
TIA
|
|
|
|
|
There's a very good basic article here[^] that will probably cover most of the bases for you. It's a time saver if you don't want to reinvent the wheel with respect to UI <-> worker thread interaction.
Hope this helps.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
Hi,
I'm completely new to this theme and I have the following problem: I want to reload the page via code like a serverside button does (PostBack event should be triggered), when beeing clicked. So, how can i achieve that?
Till now I didn't find any proper function looking in the System.Web.UI.Page class and using the meta tag <meta http-equiv="refresh" content="10"> reloads the site but triggers no PostBack event.
Thanks.
BTW: I'm using webforms and c#
|
|
|
|
|
hi,
you can cause postback with JS:
var form = document.getElementById(formID)
form.submit;
This will have same effect like user hitting submit button.
best regards,
David 'DNH' Nohejl
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
How do you plan to trigger this reload? Is it the result of a button press or ??
If it's the result of a button press (running at the server), then chances are the page is already posting back (unless you've changed the default behavior of the button).
If you're trying to do it from the client side, then you're most likely going to have to use script, as the previous post suggests, unless you're using one of the Html controls that includes a ServerClick event.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
BTW, this question really belongs in the ASP.Net forum, not this one.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
Hi,
I want to display tooltip with Item Name when mouse is hovered on a combo box items , i have done it for ListBox, but i can not able to do the same for Combo in Windows Forms using C#.
if u have any suggestions or code samples please send it to my mail.
thaking you,
shyam
|
|
|
|
|
Hi All,
A quick question. I am writing a C# application which uses Windows Sockets to create peer to peer chatting capability.
I connect the sockets up like this:
private void BeginConnectToServersThread()<br />
{<br />
String strIP;<br />
for(int nServer=0; nServer < listServers.Items.Count; nServer++)<br />
{<br />
strIP = listServers.Items[nServer].SubItems[1].Text;<br />
if(strIP != "")<br />
{<br />
try<br />
{<br />
m_socClient = new Socket (AddressFamily.InterNetwork,SocketType.Stream ,ProtocolType.Tcp );<br />
IPAddress ip = IPAddress.Parse(strIP);<br />
int iPortNo = 8221;<br />
IPEndPoint ipEnd = new IPEndPoint(ip.Address,iPortNo);<br />
m_socClient.Connect( ipEnd );<br />
WaitForData();<br />
}<br />
catch(ObjectDisposedException)<br />
{<br />
System.Diagnostics.Debugger.Log(0,"1","\n OnClientConnection: Socket has been closed\n");<br />
}<br />
catch(SocketException se)<br />
{<br />
MessageBox.Show ( se.Message );<br />
} <br />
}<br />
}<br />
}<br />
<br />
public void WaitForData()<br />
{<br />
if ( pfnCallBack == null )<br />
pfnCallBack = new AsyncCallback (OnDataReceived);<br />
m_asynResult = <br />
m_socClient.BeginReceive (m_DataBuffer,0,m_DataBuffer.Length,SocketFlags.None, pfnCallBack,null);<br />
}<br />
<br />
public void OnDataReceived(IAsyncResult asyn)<br />
{<br />
int iRx = 0 ;<br />
iRx = m_socClient.EndReceive (asyn);<br />
char[] chars = new char[iRx + 1];<br />
System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder();<br />
int charLen = d.GetChars(m_DataBuffer, 0, iRx, chars, 0);<br />
System.String szData = new System.String(chars);<br />
ProcessIncommingMessage(szData);<br />
WaitForData();<br />
}
This all works fine at the moment with a low number of servers and clients. My problem is that I also have a Web Browser control added on another form which is active at the same time as the form containing my Windows Sockets code.
Why is this a problem? Because whilst the sockets code tries to connect to existing servers (If they dont exist it can take a while before they timeout) with the m_socClient.Connect( ipEnd ) function, my Web Browser never gets to navigate to the URL I have asked it to go to!! It just sits there as if waiting for the socket connections to connect first. HMPH. I dont even get a "Page cannot be displayed", it just shows nothing at all.
If however I comment out the sockets code where it tries to connect, then the Web Browser works absolutly fine.
Any ideas why this is happening and how I can make them both work together? If you require more information then please just ask.
Thank you in advance,
Chris
|
|
|
|
|
Hi,
I am Akash Batavia. I am doing my MSc in communication and signal procc. in United kigndom,newcastle upon tyne. I am doing project on VOIP (Voice over IP).
I got some basics idea about VOIP. But I don’t know how to implement and from where to start this project.
I want to connect two computers and transfer voice form one pc to other pc using H.323.
Please help me to solve my problem. thanks.
Akash
|
|
|
|
|
If your working on your Masters, you should already be familiar with the techniques of doing your own research! Try Yahoo or Google...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I don't answer emails sent directly to me...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
We have a Datagrid in which some data is displayed. dataGrid is scrollable(with fixed header, Using div tags) and paging is not implemented.
According to some search criteria specified, I need to highlight a particular row(set selecetdIndex) in the grid.
The problem is, selected row is going out of focus as the grid is scrollable one(inside div). I mean, the row for which I need to set the selectedIndex might be the last one also.
Is there any way to auto-scroll the grid. Or Can I control the location of scroll-bar programmatically based on the selectedindex value of the Datagrid? Hope it is clear
|
|
|
|
|
Hi
I got a problem with VS 2005.
In VS 2003 there was a ContextMenu with MenuItems.
I got the following function in VS 2003.
private void menuItem1_Select(object sender, System.EventArgs e)
{
DataRowView dv =(DataRowView)this.listBox1.SelectedItem;
this.menuItem2.Text = dv["Beschreibung"].ToString();
}
In VS 2005 there is no eventHandler like menuItem1_Select. I miss that EventHandler. How can I get a text on a new toolstrip when it's selected?
Regards
|
|
|
|
|
realmontanakid wrote:
n VS 2005 there is no eventHandler like menuItem1_Select. I miss that EventHandler.
Could the .Click or .CheckChanged handlers work instead?
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Lies of Our Fathers: A Must-Know About Lent
Judah Himango
|
|
|
|
|
In the .NET 2.0, there is the new System.Net.Mail which I've been experimenting with. I cannot seem to come up with a way of changing the Content-type of my mail message to text/html. Even if I add this parameter to the MailMessage's header, the actual message's header comes through, and I will see 2 Content-type lines...the 2nd being text/plain, which puts my message back to normal text.
In the System.Net.Mime class, when I create a new mime, I can specify the content-type in the constructor as a parameter...but this seems to be the only place I have access to do this.
Is there a current way to set the Content-type in a mail message, or to set the BodyContentType to an already defined Mime variable? If there is no way, does anybody know if Microsoft is going to be adding this before the official release of VS05, and the 2.0 Framework?
Thanks for the information!!
|
|
|
|
|
OK. I am having some difficulty with processes that are spawned in a loop. For example, if a loop implements a System.Diagnostics.Process process each time through the loop, and each one of those System.Diagnostics.Process processes accesses its own individual file, the application locks the file in that process. Thus, there might be twenty files being tracked live by the Task Manager. Some of those processes will be properly opened and killed by the application sequentially before moving on to the next process, but some of those processes could not be killed when the application abends. Those processes that are not properly killed remain running in the Task Manager, and it is these processes that have not been properly killed by the application that is causing the problem.
That is, if the application abends, then some of those processes might become trapped in the Task Manager thereby preventing that loop from running again when the user might decide to run the loop again and respawn those processes. If a process is running from a past execution attempt for that portion of the application, then it cannot be executed again because the file it accesses is ALREADY LOCKED from the previous attempt to run the program. The only clean way to end those processes trapped in the Task Manager is to reboot the computer, and an end user should not need to do that to use the application. Rebooting the computer completely would remove the processes from the Task Manager, but there must be some programmatic way of doing it as well.
The attempted second execution of a process cannot occur because it is already running when the application abended. Because the process is already running, and because it accesses a specific file, it sends an error message that the file is currently being used by another process. Is there some way of pre-emptively killing these already running processes that access specific files before the user's attempt to run the program again attempts to spawn the processes again? That way, it would prevent the error message from having a change to occur. I would like to remove the actively running processes from a previous attempt at program execution of the loop before being able to run the loop again.
I am not certain how to kill existing running processes before the user's attempt to run the application again respawns those same processes again. I need to make certain that the processes that are each "locking" their specific files are killed before the user can run the program again. That way, it would be as if the program were run after freshly booting up the computer from scratch.
I realize that I might sound like I am talking in circles, but I would really appreciate some additional insight. Any assistance would be greatly appreciated.
|
|
|
|
|
Here is the problem, I have an abstract class that has a public property (type = bool). When setting the Property = true, I need to make sure two virtual functions, in the class, were overridden. I don’t want to make them abstract because they don’t usually need to be overridden. So, I looked for some way to use reflection to do this, but I haven’t made much headway. Any help is greatly appreciated.
|
|
|
|
|
ACorbs wrote:
I need to make sure two virtual functions, in the class, were overridden.
2 ways I can think of:
- use BindingFlags.DeclaredOnly when enquiring the Type for the method(s), if none returned, no override. This is limited to the class your in, might not be what you are looking for.
- get the method(s) via reflection, and check for the absence of the NewSlot MethodAttributte flag. This means it the method is overriden in the inheritance chain.
xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots
|
|
|
|
|
Thanks, I'll give it a shot. You wouldn't happen to know the proc cost of these?
|
|
|
|
|