|
Hi all,
I have to Disable 'Start' button untill the thread completes.
btn_Start_Click(object sender, EventArgs e)
{
Thread th = new Thread(new ThraedStart(Download));
th.Start();
if (th.ThreadState == ThreadState.Running) // Here i am Disabling
btn_Start.Enabled = false;
// But where i have write logic for Enabling the Button
//like if(th.ThreadState==ThreadState.Stopped) btn_Start.Enabled = true;
}
public void Download()
{
// Here i wrote logic for downloading files.
}
Please suggest me how to Disable Button until thread completes.
Thanks in Advance
|
|
|
|
|
btn_Start_Click(object sender, EventArgs e)
{
Thread th = new Thread(new ThraedStart(Download));
th.Start();
if (th.ThreadState == ThreadState.Running)
btn_Start.Enabled = false;
}
public void Download()
{
this.Invoke((MethodInvoker)delegate
{
btn_Start.Enabled = true;
});
}
|
|
|
|
|
Hi,
Thanks for your suggestion. But i already tried that one. But its giving Cross thread eroor.
Bcz, Download is running under thread th, where as btn_Start is running as main thread, so you can't change status of button of main thread in derived thread(th).
Is there any alternative .
Thanks in advance.
|
|
|
|
|
sekhar.k wrote: But its giving Cross thread eroor.
I know. I have edited the post. You need to use Invoke/BeginInvoke. Check my first reply.
|
|
|
|
|
Enable it in the last line of code in your thread
Stephen Lintott Bsc IT (RAU)
|
|
|
|
|
Hi,
Thanks for your suggestion. But i already tried that one. But its giving Cross thread exception.
Bcz, Download is running under thread th, where as btn_Start is running as main thread, so you can't change status of button of main thread in derived thread(th).
Is there any alternative .
Thanks in advance.
|
|
|
|
|
It seems to me that you don't understand what a thread is. The start method will execute COMPLETELY, and the thread will go off and do it's work. Use a WorkerThread and have it's completed event enable your button.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hi,
thanks for your suggestion. I will try it.
|
|
|
|
|
|
Hello,
How to create stored procedure dynamically in c#.net. Because
some of my requirements needs such a situation. Please help with some example code.
Thanks and Regards
|
|
|
|
|
Just execute the statements as you did for normal query. But why you need to create a SP run time? That doesn't make any sense.
|
|
|
|
|
Hi Navaneeth,
Because of requirement, I need to create tables and stored procedures at runtime. This is created at runtime because it is managed on clients system or database server during installation of application.
Thanks for reply.
|
|
|
|
|
Well, Try the following code
string query = @"CREATE PROCEDURE SampleProcedure
AS
BEGIN
SELECT 'From Sample Procedure'
END";
using (SqlConnection connection = new SqlConnection(@"YourConnectionString"))
using (SqlCommand command = new SqlCommand(query,connection))
{
connection.Open();
command.ExecuteNonQuery();
} If you have many SQL statements to be executed, I'd put it in a file and read from there to execute.
|
|
|
|
|
Could you please explain? What is the problem in this create procedure QueryString.
"CREATE PROCEDURE test.dbo.Operator @MasterField varchar(300) AS SELECT SubOperatorField FROM SubOperatorInfo WHERE MasterField=@MasterField AND departField IS NOT NULL AND SubOperatorField=somevalue";
this querystring fires an exception i.e.:-
'CREATE PROCEDURE' does not allow specifying the database name as a prefix to the object name. Must declare the variable '@MasterField'.
|
|
|
|
|
try taking the database name out of the name of the procedure
You should be already in the context of the database, e.g the SqlConnection is already connected to "test".
James
James Simpson
Web Developer
imebgo@hotmail.com
P S - This is what part of the alphabet would look like if Q and R were eliminated Mitch Hedberg
|
|
|
|
|
Thank you very much.
This works.
|
|
|
|
|
N a v a n e e t h wrote: But why you need to create a SP run time? That doesn't make any sense.
He might be coding and OR mapper
|
|
|
|
|
Then, what i do?
Can i take backup of that and the giving it for restore.
|
|
|
|
|
I put my function in a DLL(named HookDll.dll) , declare like this:
EXTERN_C __declspec(dllexport)
LRESULT CALLBACK LLMouseEventHandler(int nCode, WPARAM wParam, LPARAM lParam)
Now in a Win32 project, I call LoadLibrary("path to HookDll.dll") and it return NULL with error code is 126 (ERROR_MOD_NOT_FOUND)
I use Dependency Walker to check if there is any missing DLL that my DLL depend on , and it warn MSVCR90D.DLL is missing.
Then , I try to use P/Invoke to call LoadLibrary in a C# project
[DllImport("Kernel32.dll", EntryPoint = "LoadLibrary")]
static extern IntPtr LoadLibrary(string fileName);
And how strange , my HookDll.dll loaded successfully , so what about the missing MSVCR90D.DLL and why it can't be loaded when I call it in native way
One more thing , I found in Dependency Walker that my function was named _LLMouseEventHandler@12 , so when I call GetProcAddress , I have to use this new name , not the one I declared above. This maybe related to C++ naming convention, but I don't understand clearly
|
|
|
|
|
Hi I got this problem. It seems that when I am setting properties in wia nothing happens. The code is as follows.
foreach (WIA.Item item in d.Items)
{
foreach (WIA.Property prop in item.Properties)
{
Object obj = (Object)dpi_hor;
if (prop.PropertyID == 6147)
{
prop.set_Value(ref obj);
}
obj = (Object)dpi_ver;
if (prop.PropertyID == 6148)
{
prop.set_Value(ref obj);
}
obj = (Object)2;
if (prop.PropertyID == 6146)
{
prop.set_Value(ref obj);
}
}
}
Can someone tell me why nothing is happening specificaly with the grayscale setting. Thanks in advance
Stephen
Stephen Lintott Bsc IT (RAU)
|
|
|
|
|
This code seem weird to me. What are you expecting it to do ? Have you stepped through the debugger with it ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Yes I have. All values are set but it doesn't make a differance to the scanning. The code is right though I did a loop through the properties and looked at the names, the right properties are being set.
Stephen Lintott Bsc IT (RAU)
|
|
|
|
|
Got it figured out. Thanks anyway
Stephen Lintott Bsc IT (RAU)
|
|
|
|
|
How did you figure it out? I`m trying to set the properties in exactly the same way, but I get a "ACCESS DENIED" error
|
|
|
|
|
hello everyone,
i have problem in replaceing some content to another one..
here is my code:-
i want to replace this one to..
should be
plz help me???
|
|
|
|