|
Well, I was saying you could keep the one thread alive, but if that's your goal, then there's no reason not to create a thread for a new job, and let it die when the job ends. Then you can either choose to only have one thread running ( and have a job queue that it keeps pulling from until it ends ), or have multiple jobs going ( not likely, as I believe you have one piece of hardware to control, right ? )
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
If I'm understanding this correctly, your solution would make it so that there was only one order being processed at a time, with the thread constantly cycling and picking up the next order in line once the previous order is finished. If we were simply interfacing with a direct piece of hardware, that would work...
However (and I apologize for not mentioning this and causing the confusion), I am programming this to work with an established API from Rimage, and my client software is actually connecting to a software-system as opposed to directly to just one machine. Theoretically, there could be as many actual Rimage servers attached to the system to process 20 orders at once, and their software has its own queue internally. My application simply prepares the order, sends the ticket and monitors the status via a listener class that inherits an interface of their design. By designing each order to run in its own thread, I was attempting to maximize the use of their internal queuing system as well as the efficiency of my own program. Technically, I should be able to throw as many orders as possible at the API and it will manage the workflow on the server side...I just have to monitor the status on my end of the orders that I send.
My question regarding the threading was really me asking if there was some way to make the process that runs in the thread more event-based instead of so rigidly set inside of conditionals. Say, for instance, if I were to create events on the order object and assign handlers for those events from inside the worker thread to progress the order along, and then didn't loop the worker thread to keep it alive, the thread would just exit and those handlers would just fire into nothingness? Or would they fire on the main thread and cause exceptions because the handlers were declared inside a thread other than the UI thread and caused UI interaction indirectly when the handlers were called and the UI was updated with results (which I know enough to know that is a big no-no)?
I don't know...I've been pondering over some of these things for a few hours and been doing some more searching on the web for answers. I think I might have thought of something that will make this whole project a lot easier, but I have to flesh out the idea in the morning to make sure I'm not overlooking something...if it works, the whole threading issue might be moot.
Thanks for the advice so far, though...most assuredly this is not the end of my stupid questions
|
|
|
|
|
Don't keep worker threads alive, just create threads as you need to, one for each job. You can create a thread pool, just create a container of threads, and look through for an idle one to start, if you want a fixed number, or keep adding to it if you're happy for there to be unlimited threads.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi all,
I want that the dll of my application which are on the client machine after deployment should be protected that no one can see the code and logic using some deassembler tool. How should i protect this???
i tested a third party tool to read a dll of some trial version application from internet. Its opens the code easily, but when i tried the same tool with some system32 dll, the dll showed to be locked. I want this to be in my dll also. How is it possible ???
Sample Code, Suggestion, References welcom ........
Thanx
sandeep
|
|
|
|
|
sandeep kumar pundhir wrote: How should i protect this???
You can't. If the processor can run the executable, there will always, at some point, exist an unprotected version in order that it can be sent to the processor. Therefore there must be some way to decrypt the code for the processor, and once that is cracked then you have no protection at all. The best you can ever hope for is to slow down someone.
sandeep kumar pundhir wrote: i tested a third party tool to read a dll of some trial version application from internet. Its opens the code easily, but when i tried the same tool with some system32 dll, the dll showed to be locked.
Define "locked". Could it be that the DLL you were using was not a .NET DLL and the tool could not interpret it.
|
|
|
|
|
Please don't cross post.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
You used a tool, probably .NET Reflector to look at a .NET DLL. This is exactly what it's good for. .NET Reflector won't work on native code .DLL's, like on just about everything in the System32 folder.
What you want is not possible with a .NET DLL, or any managed code assembly for that matter. You can obfuscate the code and make it more difficult to be reverse engineered, but you cannot stop anyone from eventually getting at that code.
|
|
|
|
|
This seems to be the recurring nasty surprise about .NET. This has to tie with 'how do I deploy without needing the framework' as the top question asked.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I know. I hate answering the same question over and over again. Maybe we should put together a FAQ and post a link to it in everyone signature. "The top 10 questions asked on CP"
|
|
|
|
|
I'm bored to tears up here! I got called back into work (an hour drive) after being home for an hour and a half. Problem with IP tunnels in the WAN. I've been on hold with our "Lack of" Help Desk for just over 2 hours now waiting for them to figure out what they need to do to fix the problem.
So, what was for lunch?
|
|
|
|
|
I would like to know what happens when
you write unmanaged code in NET. The compiler
generates Intermediate Language code, but just
this code isn't "supervised" by the framework?
Also, I would like to know what happens when
you write assembly code in a .NET project. I
noticed that the __asm keyword is "syntax-hilighted".
Can machine code and Intermediate Language code exist
in the same .exe file ???
I am asking all these because, despite the fact that
I like the new capabilities the NET framework provides,
I am seriously concerned about the speed of my apps.
Thanks.
kostas KEL
|
|
|
|
|
|
1) All .NET code is converted to CLR compliant Intermiediate language code. This code is readable if you open .NET exe files in some of the native .NET debugging/.NET servicing applications. Most programmers who want to keep their code fairly safe use Obfuscators (hopefully that is spelled correctly). These applications make it harder for hackers to get the source code for the program.
2) It depends on your perspective with regards to program security with .NET compilations over native compilation.
3)One project can only have one language type files in the project. VC# applications can only have .cs files in the project, you will not be able to put VB or VJ# codefiles in the C# application. You can however have multiple assemblies or projects in the same solution that are of different languages. All compiled .NET assemblies can be used as references to VS projects of any .NET language.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
Hi,
I have been asked to take a seminar of 30 minutes on advantages of Microsoft .NET framework 2.0. Our company is currently using framework 1.1, so they want me to tell them in my seminar whats the advantage of moving to Framework 2.0.
I have to take this seminar on this friday (18 - May), can someone provide me some resources or more information on this. I dont have access to google here, but have access to code project, msdn and some .NET related web sites.
Regards,
Blumen
|
|
|
|
|
It will be better for u to access MSDN & be prepared for that event.It consist of all the features that framework 2.0 is providing along with comparison to framework 1.1.u can also have the option to get knowledge of Framework 3.0 for Cross Question.
Bye
Ashwani Kumar
|
|
|
|
|
|
I am writing a command line utility in C#. When I try to run the program from a different directory with a batch file or if I put the program folder in the Path statement I get a file not found error on the App.config file. How do I build a command line program that can be called from outside it's build or installed location?
Jay Bowman
Springfield, IL
|
|
|
|
|
Hi all,
I came across a funny and I hoped you could help, I was profiling the performance of different operations in .NET and I found that double operation was faster in debug mode, than in release mode. I created a small project to test this premise it can downloaded here.
double i, j, dTest = 0;
DateTime tmrStart;
TimeSpan spanCost;
tmrStart = System.DateTime.Now;
for(i = 0; i < 100000; i++)
{
for(j = 0; j < 100000; j++)
{
dTest += i+j;
}
}
spanCost = System.DateTime.Now - tmrStart;
Console.WriteLine("Test took {0} milliseconds", spanCost.TotalMilliseconds);
The project code is the same as above code snippet. All my optimizations are set to the project defaults. Surely this can't be right ??? I have tested this on two boxes; my laptop and a performance machines with multiple processors and acres of ram, and I getting comparable results on both. So what am I doing wrong ?
C:\Documents and Settings\Administrator\Desktop\DoubleTrouble\DoubleTrouble\bin>
debug\doubletrouble.exe
Test took 82218.75 milliseconds
C:\Documents and Settings\Administrator\Desktop\DoubleTrouble\DoubleTrouble\bin>
release\doubletrouble.exe
Test took 311218.75 milliseconds
C:\Documents and Settings\Administrator\Desktop\DoubleTrouble\DoubleTrouble\bin>
|
|
|
|
|
Confirmed. Weird!
I looked at the IL between the two version. Ther'yre not that much different at all. Both are doing just about the exact same thing, with the Debug version peppered with NOP instructions and a couple of extra blocks like this:
ldc.r8 10000.
stloc.s VB$CG$t_double$S0
ldloc.s VB$CG$t_double$S0
ble.s IL_001b
The Release version doesn't have the to stloc.s and ldloc.s instructions, but it otherwise identical.
If you were to read through the IL only, you'd say that the Debug version must run slower! Hmmm....
|
|
|
|
|
I examined the IL earlier and thought they where more or less identical.
Will have another look, thanks for the confirmation. I am not sure where this leaves me though.
|
|
|
|
|
Sorry but all looks fine to me. I ran three consecutive tests
Release: Test took 36026.0145 milliseconds
Debug: Test took 91831.0365 milliseconds
Release: Test took 38050.299 milliseconds
Debug: Test took 92406.195 milliseconds
Release: Test took 36189.09 milliseconds
Debug: Test took 86926.077 milliseconds
Is it a 1.1 vs. 2.0 issue? Your projected needed to be converted when I opened it in VS2005.
-- modified at 14:30 Tuesday 15th May, 2007
only two letters away from being an asset
|
|
|
|
|
I got just the opposite using VB.NET 2005 and my own code.
Could be a JIT issue with a certain proc, maybe??
I've run it on a Pentium M 1.7GHz. Intel x86, Family 6, Model 9, Step 5.
|
|
|
|
|
VB.NET! Well that says it all
I tested on a AMD Athlon 64 X2 Dual Core 4800+ running Vista 64bit using C#.
only two letters away from being an asset
|
|
|
|
|
Hmm... OK. I've got a little time to try this in C# too. Hang on.
|
|
|
|
|
Well, not so fast. Rewriting the test in both languages, I got the same results as you. The Debug version is now SLOWER
The VB.NET version I used:
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Button1.Enable = False
Application.DoEvents()
Dim i, j, t As Double
Dim StartTime As DateTime = DateTime.Now
For i = 0 to 10000
For j = 0 to 10000
t += i + j
Next
Next
Dim EndTime As DateTime = DateTime.Now
Dim TotalTime As TimeSpan = EndTime - StartTime
Console.WriteLine("TotalTime: " & TotalTime.TotalMilliseconds)
Button1.Enabled = True
End Sub
The C# version is, line-for-line, identical to this, even the IL is the same.
using System;
using System.Collections.Generic;
using System.Windows.Forms;
blah, blah, blah
namespace Double_Performance_Test
{
public partial class Form1 : Form
{
public Form1()
{
InitalizeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
button1.Enabled = false;
Application.DoEvents();
double i, j, t = 0.0;
DateTime StartTime = DateTime.Now;
for (i=0; i < 10000; i++)
for (j=0; j < 10000; j++)
t += i + j;
DateTime EndTime = DateTime.Now;
TimeSpan TotalTime = EndTime - StartTime;
Console.WriteLine("Total Time: " + TotalTime.TotalMilliseconds);
button1.Enabled = true;
}
}
}
Both get the same results:
Debug: avg of 3460 ms
Release: avg of 820 ms
-- modified at 16:48 Tuesday 15th May, 2007
|
|
|
|