|
Hi All,
I'm creating a multi-threaded application where I'm spawning a new thread from the main thread. I've to execute the child thread once the main thread finishes its execution. I cannot put the code of child thread inline to the main thread as the thread does some work that I do not write code for. Once the main thread finishes doing everything the child thread execution starts.
I was wondering if there is something like Thread.Idle (like Application.Idle) event so that i can start the execution of the new thread. Or is there a better way to accomplish this.
An help will be deeply appreciated
TIA
Pavan K Kulkarni
|
|
|
|
|
|
I can't do that because I do not know when exactly the main thread finishes its execution. I want this to happen automatically...that was my question.
Pavan K Kulkarni
|
|
|
|
|
Hello everyone
I am trying to start a windows application at a specified time from a windows service, i am calling
System.Diagnostics.Process.Start(Filepath),
although the program starts when i saw it in the task manager but it does not show its form. i have also tried
System.Diagnostics.Process.Start("cmd", "/c \"" + Filepath + "\"")
but it opens a command window with my application which i dont want to open. is there any other function.
Shajeel
|
|
|
|
|
You can start the process, but windows service can't have window. A solution can be window application (form) that appears invisible all the time.
|
|
|
|
|
Basically i want to stop a running application made some changes to it, and then restart it from the service.
Shajeel
|
|
|
|
|
I have a datagrid with checkbox column. how can give access to user select only one check box at a time.
|
|
|
|
|
And which kind of application is? windows form or web
|
|
|
|
|
Windows application using C#
|
|
|
|
|
Why do you need to use a check box? This type of functionality should be done with radio buttons.
Roy.
|
|
|
|
|
I’m using a third party ActiveX control in my .NET Application. I manage to handle the callback in unmanaged C++ like this:
class MyCallback : public ICallback<br />
{<br />
…<br />
void OnComplete() {…}<br />
}<br />
<br />
…<br />
MyCallback *callback = new MyCallback();<br />
someobject->SomeFunction("just a string", callback);<br />
The function OnComplete is apart of the ICallback interface.
In C++ the method OnComplete will be called some seconds after SomeFunction has been called.
How do I translate that into C#?
I’ve come this far:
public class MyCallbackSC : ICallback<br />
{<br />
…<br />
void OnComplete() {…}<br />
}<br />
<br />
…<br />
MyCallback callback = new MyCallback();<br />
someobject.SomeFunction("just a string", (object)callback);
My C# program compiles fine but when I got an exception on the codeline above that says: InvalidCastException.
Anyone got any ide how to handle callbacks in C#...?
_____________________________
...and justice for all
APe
|
|
|
|
|
If i have several dll's in my solution
Is it then possible to include them in my EXE file, instead of them flooding my launch directory?
I dont want to put them in the gac or anything. Just want them included in the EXE file somehow..
Kind Regards
CS
|
|
|
|
|
Make search on word "obfuscator"
|
|
|
|
|
ILMerge[^] might be what you are looking for.
|
|
|
|
|
i want to implement SSL in my web project..but getting error ..as when i teried to upload the certificate on the web server .it is giving me error of wrong key .. can any one who has implemented this help...? my IIS version is 5.0 and using verisign's trial SSL certificate
|
|
|
|
|
Hi I am trying to change the background image of the picturebox on the mousedown event. to show that it is pressed. but the problem is when i give the path of the image it gives the error that
cannot implicitly convert type string into system.drawing.image
so tell me how can i do this conversion
Regards,
|
|
|
|
|
Bitmap.FromFile(yourstring);
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
I want to transfer string value from C# to javascript in asp.net.
For that, I am trying in two ways one is hidden variable and other is label tag but both are getting an error message.
Here the code:
Using hidden:
<script language = "C#" runat="server">
string img_name = "image1.jpg#image2.jpg#image3.jpg";
hide_imgname.value = img_name; // error: hide_imgname is not defined
</script>
<script language = "javascript">
string js_imgname = hide_imgname.value; // error: hide_imgname is not defined
</script>
.
.
.
<input type="hidden" name="hide_imgname"/>
Using label:
<script language = "C#" runat="server">
string img_name = "image1.jpg#image2.jpg#image3.jpg";
Message.Text = img_name; // Now here no error.
</script>
<script language = "javascript">
string js_imgname = Message.Text; // error: Message is not defined
</script>
.
.
<asp:label id="Message" visible="false" runat="server"/>
Please help me to sort out this problem.
Thanks
-- modified at 6:17 Monday 8th May, 2006
|
|
|
|
|
Three things wrong here
1 - you're treating ASP.NET as if it was ASP - stop it. You should put all your code in the code behind, not inline
2 - C# runs on the server, jscript runs on the client, they will never be able to see each other
3 - This is best asked in the ASP.NET forum.
In your code behind you can use the InsertClientScriptBlock ( from memory ) function to insert jscript into the generated code. You should call this in your codebehind, assuming you have a meaningful example, as opposed to what you posted.
Actually, your jscript could use findelementbyID to find your textbox and get it's value.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
Can you please send me sample example using InsertClientScriptBlock
Thanks
|
|
|
|
|
|
Yeah, I thought I may have the name wrong....
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
i would like to send a live stream webcam image over a local area network with C#
but i don't have any information about it...
do you guys have some information about it...
|
|
|
|
|
Hi all,
I'm working with VC++ for several years and have used the MFC libraries to create all my applications.
But now I need to use C# to make a thick client application. In order to make it user friendly I certainly need to use threads. In VC I used both 'Worker' and 'User' threads, so I want to use both in the new client. Although I found how to use worker threads, I didn't find any references how to create user threads in C#.
Does anyone has any thougts on how to implement a user thread in c#?
Thx in advance
codito ergo sum
|
|
|
|
|
Include System.Threading in your using list:
--------------------
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.IO;
using System.Diagnostics;
using System.ServiceProcess;
using System.Threading;
using System.Configuration.Install;
using System.Reflection;
Define your threading variables:
--------------------
private static System.Threading.Thread ReadFromDTThread;
private static System.Threading.Thread IsAliveThread;
private static System.Threading.Thread WriteToLX1Thread;
private static System.Threading.Thread IsActiveThread;
-----
and any global variables in your class:
-------
private System.ComponentModel.Container components = null;
private static System.Collections.Queue LX1Queue = new Queue();
private static System.Text.StringBuilder datatracSql = new System.Text.StringBuilder(5000);
private System.ComponentModel.Container components = null;
private static System.Collections.Queue LX1Queue = new Queue();
private static System.Text.StringBuilder datatracSql = new System.Text.StringBuilder(5000);
private volatile static int RestartCount = 0;
private volatile static bool InterfaceStop = true;
private volatile static bool InterfacePaused = true;
private volatile static bool Interface1Alive = false;
private volatile static bool WriteToLX1Alive = false;
---------------
Declaring boolean and integer variables volatile tells the compiler to make no assumptions about the state of variables. It makes simple operations on these variables safe for multithreading without the need for locking (atomic).
Write your methods that will be performed in your threads:
--------------
private static void WriteToLX1()
{
int ErrorCount = 0;
int qCount = 0;
if (generalSwitch.TraceInfo)
Trace.WriteLine("DT2LXInterface:WriteToLX1 has started.");
while (true)
{
//Set Alive flag so that IsAlive knows thread is running
WriteToLX1Alive = true;
Hashtable LoanData;
//Lock queue use SyncRoot to perform sync on objects that have this method
lock (LX1Queue.SyncRoot)
{
qCount = LX1Queue.Count;
}
if (qCount == 0)
{
//Flush the current sql statements--write all pending data to LX when queue goes empty
LXData.IAccess.ExecuteBatchAdHocFlush();
//End thread if there are no records in the queue and interface is stopping
if (InterfaceStop)
return;
Thread.Sleep(InterfaceCycleTime);
continue;
}
lock(LX1Queue.SyncRoot)
{
LoanData = (Hashtable)LX1Queue.Dequeue();
}
NBPropertyBag getInfo = new NBPropertyBag();
getInfo.Contents = LoanData;
string AcctNO = getInfo.ReadProperty("_accountnumber");
string Label = getInfo.ReadProperty("_label");
string FileID = getInfo.ReadProperty("_fileid");
if (generalSwitch.TraceVerbose)
{
Trace.IndentLevel =0;
Trace.WriteLine("");
Trace.WriteLine(System.DateTime.Now.ToString());
Trace.WriteLine("--------------- DT2LXInterface:WriteToLX1 Determine BLL Start ----------------");
Trace.Indent();
Trace.WriteLine("AcctNO/Label/FileID" + AcctNO + "/" + Label + "/" + FileID);
Trace.Unindent();
}
// Use label to determine which BLL to Call
try
{
switch (Label)
{
case "GenUpdate":
clsDt2LXGenBLL.HandleMessage(LoanData);
break;
case "UndUpdate":
clsDT2LXUndBLL.HandleMessage(LoanData);
break;
case "MktUpdate":
clsDT2LXMktBLL.HandleMessage(LoanData);
break;
case "FunUpdate":
clsDt2LXFunBLL.HandleMessage(LoanData);
break;
case "FeeUpdate":
clsDT2LXFeeBLL.HandleMessage(LoanData);
break;
case "ImpUpdate":
clsDT2LXImpBLL.HandleMessage(LoanData);
break;
case "ActUpdate":
clsDT2LXActBLL.HandleMessage(LoanData);
break;
case "MersUpdate":
case "MersMomUpdate":
clsDT2LXMersBLL.HandleMessage(LoanData);
break;
case "ELIUpdate":
clsDT2LXELIBLL.HandleMessage(LoanData);
break;
case "CorUpdate":
clsDT2LXBrokerBLL.HandleMessage(LoanData);
break;
};
if (generalSwitch.TraceVerbose)
{
Trace.IndentLevel = 0;
Trace.WriteLine("--------------- DT2LXInterface:WriteToLX1 Determine BLL Finished ----------------");
}
StagedLoansProcessed++;
//Data from datatrac was added without any issues
ErrorCount = 0;
if (DT2LXBaseBLL.status != 0)
{
//There were minor issues
LogUtil.AddToInfoRow(AcctNO, FileID, "1", "1" + Label, DT2LXBaseBLL.issue);
DT2LXBaseBLL.ClearIssue();
}
}
catch (Exception e1)
{
if (generalSwitch.TraceError)
{
Trace.IndentLevel = 0;
Trace.WriteLine("");
Trace.WriteLine(System.DateTime.Now.ToShortDateString());
Trace.WriteLine("-----------Error in WriteToLX1----------------");
Trace.Indent();
Trace.WriteLine(e1.Message);
Trace.WriteLine("AcctNO/Label/FileID" + AcctNO + "/" + Label + "/" + FileID);
Trace.IndentLevel =0;
Trace.WriteLine("-----------Error in WriteToLX1----------------");
}
if (e1.Message.IndexOf("ORA-01033") > -1 || //Oracle shutdown
e1.Message.IndexOf("ORA-12154") > -1 || //Bad TNS name
e1.Message.IndexOf("ORA-01017") > -1 || //Bad userID/password
e1.Message.IndexOf("ORA-06576") > -1) //stored procedure not found
{
//Can not recover from these errors; shutdown interface
EventLog.WriteEntry(MyServiceName, "Non-recoverable error--terminating WriteTOLX1: " + e1.Message ,
EventLogEntryType.Error);
WriteToLX1Alive = false;
return;
}
//Data from datatrac was not added to LX for some reason
//Try again
string secondTry = getInfo.ReadProperty("_secondtry", "F");
if (secondTry == "F")
{
getInfo.WriteProperty("_secondtry", "T");
LoanData = getInfo.Contents;
lock (LX1Queue.SyncRoot)
{
LX1Queue.Enqueue(LoanData);
}
}
if (ErrorCount > MaxErrorCount)
{
EventLog.WriteEntry(MyServiceName, "More than" + MaxErrorCount.ToString() + " errors in succession, terminating WriteToLX1 thread. Thread will be restarted.", EventLogEntryType.Warning);
WriteToLX1Alive = false;
return;
}
}
}
}
------
Then you can start the thread in the main class by calling:
--------
//The method on this thread will try to Send loan to LX
//If it fails to import the loan it will update the try count by one
WriteToLX1Thread = new Thread(new ThreadStart(WriteToLX1));
WriteToLX1Thread.Name = "WriteToLX1";
WriteToLX1Thread.Priority = ThreadPriority.AboveNormal;
WriteToLX1Thread.Start();
//Allow thread to execute on uniproccessor machine
Thread.Sleep(0);
-------
The Thread.Sleep(0) must be done after creating the thread to make it safe for uniproccessor machines. If you do not call this on a uniproccessor machine the child thread will never start.
|
|
|
|