|
...
"Well, we're getting "F"'d at work. WPF, WCF, and WWF... WTF?" --John Simmons
|
|
|
|
|
In the code, set CanStop to false.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
When the press of a button Alt + Ctrl + Delete and terminate the Service
|
|
|
|
|
hi,
i have a server application that the req from clients are answered with a seperate thread and my windows form(my user interface) is answering the user.
recently i've added a new button that would open me a savefile dialog, another button for openfiledialog and the last for folderbrowserdialog.
first button:
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
}
sec button:
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
textBox_bak.Text = openFileDialog1.FileName;
}
third button:
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
}
thhere is a weired problem with first button and the sec button, when i hit them my thread won't work and won't answer to clients untill the (save or open)dialog is open
but button 3 is not like them.
|
|
|
|
|
i should mention that this problem occured in XP but not vista(i mean vista was ok!)
there should not be any difference, should be?
|
|
|
|
|
Hi,
the GUI Controls are not thread-safe; Windows requires that a Control only be
accessed by the thread that created it (normally the GUI thread for all of them, since
they typically are all linked in one big hierarchy). When other threads need to report
and show some results using the GUI, there is an Invoke mechanism, supported by
Control.InvokeRequired and the methods Control.Invoke() or BeginInvoke() methods.
if you fail to obey the rules, the GUI may seem fine for a while, for some of its Controls,
on some machines, on some operating system, but in general it is destined to fail.
final remarks:
- since NET2.0 illegal cross-thread calls throw an exception; there is a property to suppress those
and that is a very bad idea.
- also since NET2.0 there is a BackGroundWorker class that is useful in dealing with background work
needing to update the GUI.
Luc Pattyn [Forum Guidelines] [My Articles]
I use ListBoxes for line-oriented text output (not TextBoxes), and PictureBoxes for pictures (not drawings).
modified on Friday, June 10, 2011 12:19 PM
|
|
|
|
|
thanks for you'r nice answer, but i know the rules, i have userd Invokde every where that i need to point a func or obj created outside of the thread. so what is the solution? u just explain me why this happened?
u mean a way is to use background worker instead of separate thread?
|
|
|
|
|
Hi,
you need to provide more information on the situation. How many threads/threadpools/backgroundworkers are there? how many are involved in accessing Controls (even reading a property)?
you should also consider hidden threads, serving asynchronous actions such as timer events, serial port
or network data received, probably also remoting, etc.
Luc Pattyn [Forum Guidelines] [My Articles]
I use ListBoxes for line-oriented text output (not TextBoxes), and PictureBoxes for pictures (not drawings).
modified on Friday, June 10, 2011 12:19 PM
|
|
|
|
|
It is my only thread i have settings file in common with my GUI and thread(i user Control.Invoke to reach to my Settings.xml ), there is no background worker. my thread is no timer, no serial port,
my thread just listen to network for any incomming clients(Listener.AcceptTcpClient()) and answer those clients according to what is on my sql database. and that's all, i am so Confused
|
|
|
|
|
Hi,
I still don't get the overall architecture of your app. If you want help, then please explain yourself.
This is what I got so far:
- it is a server app; AFAIK most servers create a thread for every incoming request, so each request can get handled at its own pace (the alternative of just queueing all requests and handling them one by one does not scale well).
- you use AcceptTcpClient() which is a blocking call; if you do this on the main thread, the GUI dies
until a client comes in??? otherwise, you need a separate thread that accepts clients and dispatches them.
suggestions:
- explain the architecture, using real names;
- show actual code, not just a skeleton; but not hundreds of lines, just the relevant pieces.
- when in doubt about threading use either someControl.InvokeRequired; whenever it returns true you need
to use (Begin)Invoke
- and/or when in doubt about threading, log the Thread.CurrentThread.ManagedThreadId so you can compare
it to the one of the GUI thread (by logging ManagedThreadId say inside a form load handler).
|
|
|
|
|
how can i get the contents of a variable that i declared as SqlDataReader in String format? like writing it to a file or whatever way that's easier. the code looks like below:
SqlConnection cnnConnection = new SqlConnection();
cnnConnection.ConnectionString = "Data Source=.;Initial Catalog=TestDB;User ID=sa;Password=123";
cnnConnection.Open();
SqlCommand myCommand = new SqlCommand();
myCommand.Connection = cnnConnection;
myCommand.CommandType = CommandType.Text;
myCommand.CommandText = "select cname from testtable";
SqlDataReader sdr = myCommand.ExecuteReader();
--- Thanks
|
|
|
|
|
They hide that information in something called documentation[^]
only two letters away from being an asset
|
|
|
|
|
Hi,
I was trying to automate MSExcel using C#. I face a problem when I was trying to open a workbook for the second time, throwing up a message
"xls is already open. Reopening will cause any changes you made to be discarded." inspite of releasing the Workbook Object. Any help to suppress the message would be greatly appreciated.
Thanks in advance.
Code snippet used.
m_oWorkBook = m_oWorkBooks.Open(strFileName, m_objOpt, false, m_objOpt, m_objOpt, m_objOpt, m_objOpt , m_objOpt, m_objOpt, true, m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt); //open a workbook
.... //Some operation.
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();
Marshal.FinalReleaseComObject(m_oWorkBook); // release the workbook
Other Excel COM Objects which are acquired are also released in the proper sequence.
|
|
|
|
|
KarthikonIT wrote: GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();
Why ??
|
|
|
|
|
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();
Is basically used to cleanup Underlying COM Objects for which we don't have reference.
Please visit the below mentioned URL for more details.
http://www.xtremevbtalk.com/showthread.php?t=160433[^]
Thanks.
|
|
|
|
|
How can we detect if a user is idle on a certain webpage for a certain period of time.
The problem i'm facing is the following:
I have a webpage that contains an iframe to another page where in the iframe the page is sent with login parameter. after a certain amount of time the iframe's page timeout without being refreshed so the links in that page are still there but when click one of then you're redirect to a login page. I wish to refresh my main page if the user is idle.
I hope the idea is clear.
Thanks you,
Best Regards.
Mazen
|
|
|
|
|
Wow - C# questions in the ASp.NET forums, and ASP.NET questions in the C# forum.
You can do this with javascript. You can't do it with C#, obviously.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
How can i do this in JavaScript: what's the syntax? the code for it? i've tried a few script but you can just set them to do what i'm asking for, for an interval of time without detecting if the user is idle or not. this means if the user is working on something in the iframe he'll loose his work. if you have the code please send it so i can try it.
Best regards,
Mazen.
|
|
|
|
|
|
lavankumar wrote: we want to break dongle key in hardware device.
what do you mean ? dongles are there for a reason - copyright, security, i/p protection etc if you want to do something illegal please take your request elsewhere - no one here will help you with such - if you had a valid request, maybe the best place to start is the hardware device manufacturer
'g'
|
|
|
|
|
break that device from 3 or 4 floors
|
|
|
|
|
lavankumar wrote: In my project we are using C# .net .in this we are using hardware device .
we want to break dongle key in hardware device.
Here is the code
BreakHWKey _objBreakKey = new BreakHWKey();
if (_objBreakKey.breakKey("Hammer", "screwdriver", "Guess"))
{
Party();
}
else
{
}
Main Class
class BreakHWKey
{
public bool breakKey(string Instrument1, string Instrument2, string Progrmmer)
{
YourDevice.Break();
return true;
}
}
|
|
|
|
|
Hi Everyone,
I am usnig VS05 + c# + Gridview + Web Application.In my application i have a function FillGrid() where data from my userinformation table is filled.
I want to fill the data in gridview such that when user type "s" in textbox at that time automatically data which is having username = "s" is filed in gridview.
In short when user type lettrs at that moment the data related to textbox should filled in gridview.
How can i do this?
Thanks in advance.
|
|
|
|
|
sanpune wrote: I am usnig VS05 + c# + Gridview + Web Application
So you should have post the question in asp.net forum
sanpune wrote: I want to fill the data in gridview such that when user type "s" in textbox at that time automatically data which is having username = "s" is filed in gridview.
Use Ajax .
For your reference[^]
|
|
|
|
|
Hello,
I have a requirement of modifying the datasource of crystal report as per user select option from form. As records per each selection are too much which reduces the performance of application, so I need to do in this way. I tried to change the datasource by setting setdatasource command but it doesn't refresh the data in report.
Thanks in advance
Regards
Ali Raza
|
|
|
|