|
See, that is what you get from a poor choice of an identifier name, what you have implemented is a "PleaseContinue" flag: as soon as you set it false, the worker threads have nothing left to do, and terminate.
If OTOH you want a "TemporarilySuspended" flag (I switched polarity here!), something you could set true and false repetitively and your worker threads would obey, then you need your worker threads to wait for it to become true again. An AutoResetEvent may be a good choice then.
Anyway, IsActive is a bad name, as it does not describe a state, it is intended to give a command.
|
|
|
|
|
Yes correct, in my initial post I realize that the threads were behaving exactly as they should and just ended when the variable broke the workers out of the Wloop.
Basically, I want the two workers threads to constantly be running, and then when the shared variable is set to true they then start doing work. Then when the user clicks the button again the worker threads "pause" and wait for the next time the variable is set to True.
The "IsActive" name was just an abstraction. I use a much more detailed name in my actual code.
In regard to the "TemporarilySuspended" flag and AutoResetEvent, could you provide some examples, would love to handle that properly.
Thanks a bunch for the help!!
|
|
|
|
|
I suggest you start by reading MSDN on the subject of AutoResetEvent class, the examples are adequate IMO.
|
|
|
|
|
how to cut a receipt using vb6?
|
|
|
|
|
VB6 is no longer supported by Microsoft and therefore there are very few support resources. You need to rewrite the app into a supported language.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I'm may throw up because I'm supporting a V6 user, but you have to dig out the manual on the printer and get the character sequence to send to the printer to tell it to cut the receipt. Then you modify your code to send that character sequence when your receipt printing code is done.
|
|
|
|
|
Can anyone give me a sample data model of a flight reservation?
|
|
|
|
|
Why? Asking questions about YOUR code would be a bit more productive than copy'n'pasting someone elses code.
That's not something you're going to come acrossed in the public domain. Usually something like that is going to be a part of a VERY expensive piece of software.
|
|
|
|
|
|
Hi I use wiaaut.dll to scan, but in some PC it's not work because it not register in PC. How I register this dll programatically and only one time?
|
|
|
|
|
You don't do it from your app code. This is a problem that's easily solved at install-time. Create an installer for your app, add the .DLL to it and the installer will register it for you.
|
|
|
|
|
I use Smart Install Maker, are this installer make this? Are this dll is ActiveX, because in this installer have a ActiveX section
modified 11-Mar-12 11:10am.
|
|
|
|
|
Never heard of it. I have no idea.
.NET cannot target building a true ActiveX component. You've built a COM-exposed library. I have no idea if Smart Install Maker handles .NET assemblies properly and regsiters them. You'll have to contact the people that make Smart Install Maker for that.
|
|
|
|
|
Yes Smart Install Maker register Wiaaut.dll and it work perfect . THANKS
|
|
|
|
|
Shell "regsvr32 /s c:\windows\system32\Wiaaut.dll"
|
|
|
|
|
if db_id('DSX') is not null
Print 'DATABASE EXISTS'
else
Print 'DATABASE DOES NOT EXISTS'
This query result a normal text,
but when i use this,
Output = CStr(cmd.ExecuteScalar())
Output = Nothing
Am I wrong by using ExecuteScalar??
Thankyou before,
|
|
|
|
|
ExecuteScalar returns the value in the first column of the first row of the result set. I don't believe SQL Print qualifies as the result set, so it should return nothing at all.
SQL Print messages are returned by the SqlConnection object, in the InfoMessage event.InfoMessage event[^].
But, in your case, I think you'd be better served by returning a 1 or a 0 in a result set instead of handling a text message to determine state.
|
|
|
|
|
Replace the Print keyword with Select keyword and it should work.
|
|
|
|
|
Would the gentleman who downvoted this answer own up and explain?
|
|
|
|
|
Hi all, Hope someone can help with this...
I wrote this code several years ago and it has worked great in XP. Our department is rolling out Windows 7 and the agency that uses the app I wrote are finally receiving their new Windows 7 systems.
One problem... code doesn't work any longer.
The code sets up a DSN entry on the fly. In XP, a standard user without any elevated rights could run the app and this code worked.
Now in Windows 7 when installing, I have the end user setup as local administrator and the app fails to Create the DSN. If I go in and right click on the "Click-Once" setup.exe and select "Run as administrator" it works. Also if I create a shortcut to the setup.exe and change the advanced settings to "Run as administrator" it also works from that shortcut.
If I use the icon created by the program from the "Start" menu or from the desktop, which doesn't have an option to "Run as administrator", even though the client is setup as local administrator, it kicks an error that it can't create the DSN. I can delete the DSN and see when it is created and when it can't and it coincides with the trials I've listed above.
Is there something I can put in code that allows it to work no matter if administrator or if a standard user, like it did in XP? Some google posts talk about UAC causing the problem, but just say they recommend to run as administrator.
I've searched google and code project, and most articles / posts seem to be from 2004 or around that time. We're using VS 2010... Is there a better way to creat the DSN's on the fly with VS 2010?
Here is the code
<br />
Public Declare Auto Function SQLConfigDataSource Lib "ODBCCP32.DLL" _<br />
(ByVal hwndParent As Integer, ByVal fRequest As Integer, ByVal lpszDriver As String, ByVal lpszAttributes As String) As Integer<br />
<br />
Private Const ODBC_ADD_SYS_DSN As Integer = 4<br />
<br />
Friend Shared Sub Create_DSN_For_Crystal_Reports()<br />
Try<br />
Dim attributes As New System.Text.StringBuilder()<br />
Dim returnCode As Integer<br />
<br />
attributes.Append("DSN=CCPROD")<br />
attributes.Append(Chr(0))<br />
attributes.Append("Server=CCPROD")<br />
attributes.Append(Chr(0))<br />
attributes.Append("Description=DSN added via code from Beneficiary System")<br />
attributes.Append(Chr(0))<br />
attributes.Append("Database=HrPr")<br />
attributes.Append(Chr(0))<br />
attributes.Append("AnsiNPW=Yes")<br />
attributes.Append(Chr(0))<br />
attributes.Append("QuotedId=Yes")<br />
attributes.Append(Chr(0))<br />
attributes.Append("Trusted_Connection=Yes")<br />
attributes.Append(Chr(0))<br />
attributes.Append(Chr(0))<br />
<br />
returnCode = SQLConfigDataSource(0&, ODBC_ADD_SYS_DSN, "SQL Server", attributes.ToString)<br />
<br />
If returnCode <> 1 Then<br />
Throw New Exception("DSN could not be setup to allow Crystal Reports access - Contact Programming Staff")<br />
End If<br />
Catch ... <br />
...<br />
End Try<br />
End Sub<br />
Lost in the vast sea of .NET
|
|
|
|
|
I really have to ask why you're even bothering with a DSN?? Do you know what a DSN is?? It's a connection string in a text file.
Since your code can use a connection string directly without the DSN, why are you even bothering with it?
|
|
|
|
|
The DSN is being setup for the Crystal reports that are initiated by the application.
Lost in the vast sea of .NET
|
|
|
|
|
OK. Crystal Reports doesn't exactly require using a DSN either, but whatever.
By default, users on Vista and 7 run as normal users, even if they are Admin accounts. UAC will usually prompt for admin creds if an app requires admin level priv's.
Add a manifest to your application and modify it to require admin priv's when it runs. See this[^] for the full details.
Warning! If UAC is turned on on Vista and 7, every time your app runs, it will ask for the users credentials or at least warn them that the app will be running as an admin.
|
|
|
|
|
Thanks Dave!
This worked very well in Windows 7 without breaking the app for my XP clients.
I was looking at your profile. Congratulations on all the MVP awards over the years! I don't post much on Codeproject, just a couple questions and a few answers a year, but I believe you've probably answered most of my posts. I see you hit 9 years as of today, March 12th, Congratulations...
Thanks again for your help!
Lost in the vast sea of .NET
|
|
|
|
|
give some codes for audit trail in vb.net
|
|
|
|