|
Maybe Thread.SpinWait could help you.
More time resolution is only available with multimedia timers or DirectX.
Acting as a substitute for God, he becomes a dispenser of justice. - Alexandre Dumas
|
|
|
|
|
Can it sleep from 1 micro second?
/\ |_ E X E GG
|
|
|
|
|
|
I have a simple console app I created in C#.net. Can I just distribute the exe ?
We use to be able to this ..
When I give it to some people it says "NTVDM CPU has encountered an illegal instruction". I gave the exe to people running WIN2K and WINXP. Do I need to distribute files with a console app. ( yes, they do have .NET 1.1 running on their machine )
It does work on developers machines though ..
ANYONE ??
|
|
|
|
|
Dato wrote:
When I give it to some people it says "NTVDM CPU has encountered an illegal instruction".
I've seen this kind of behavior with some viruses which doesn't understand the format of a .EXE .NET assembly and corrupt it. See if your customer's machines aren't infected.
Acting as a substitute for God, he becomes a dispenser of justice. - Alexandre Dumas
|
|
|
|
|
For some reason ..
You can't throw around Console exe anymore. Even if the .NET framwork is on the target machine. I had to create a setup project and it worked fine..
I need to read more on distribution really... I don't understand all the ins/outs...
|
|
|
|
|
This behavior does not have anything to do with .NET framework but with restrictions with the cmd under those machines. Look into:
http://www.derkeiler.com/Mailing-Lists/securityfocus/pen-test/2003-05/0115.html
To bypass these restrictions.
|
|
|
|
|
Thks anonymous ..
Will look into it..
|
|
|
|
|
O.K. this is just out of interest as I've decided to use GDI+ but I was wondering if anyone knows how to double buffer a direct draw window as part of a standard windows application. The problem as I understand it is that for the double buffering to work the device needs to be exclusive which means it needs to be full screen and I've tried and failed to create a back buffer and then draw the data to the back buffer before drawing the back buffer to a primary buffer. Note though that you can't set up the back buffer as a true back buffer because of the exclusive problem so it was set up up as an offscreen surface.
So anyone with any ideas that might just be stupid enough to work?
pseudonym67
Neural Dot Net Articles 1-11 Start Here[^]
|
|
|
|
|
I'm pretty sure that there's an article or two here on CP that shows how to do this (maybe as just a side-light to the real article, though).
John
"We want to be alone when we hear too many words and we feel alone when it has been a while since anyone has spoken to us." Paul David Tripp -- War of Words
|
|
|
|
|
Steps:
1) Create a bitmap the size of the area to be painted.
2) Create a Graphics from the bitmap, using Graphics.FromImage.
3) Use the Graphics object's drawing functions to draw on the bitmap.
4) Use Graphics.DrawImageUnScaled to draw the bitmap onto the screen.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Cheers I'll have a play with that when I get chance. The GDI+ stuff didn't take that long to get working so it's just out of curiosity to see if it works.
pseudonym67
Neural Dot Net Articles 1-11 Start Here[^]
|
|
|
|
|
I've always passed around a reference to an instance of a Logger in most apps that I've developed. There has to be a better way. What do you guys do? I'd like to make a single instance that can be used anywhere in the program. Should I be considering a Singleton design pattern.... ???
I don't need anything fancy. All I need to do is:
MyLogger.Log("Message");
Is it possible to make an instance global to a namespace?
|
|
|
|
|
|
Write a logger class that has a single static method:
public class Logger {
static public Log(string msg);
}
Then you would call the Log method like this:
Logger.Log("Sent a message");
Of course the logger class would have a bunch of private methods and classes underneath to use a logging instance of some type that does the work.
An alternative is to write a classic Singleton.
Cheers, Julian
Program Manager, C#
This posting is provided "AS IS" with no warranties, and confers no rights.
|
|
|
|
|
Inherit a class from System.Diagnostics.TraceListener. On application start, add an instance of this class to the System.Diagnostics.Trace.Listeners and/or System.Diagnostics.Debug.Listeners collections.
Every time you use Trace.Writexxx or Debug.Writexxx, it will be logged through your class. If you change/expand your logging facilities at some time, you don't have to change any client code, just your TraceListener.
|
|
|
|
|
I am launching a cmd prompt via my C# app that runs "net stop mssqlserver /y". This works in Debug mode, but the compiled application opens the cmd window and then closes it immediately without executing the line. Anyone else experienced this?
Attatching debug app exe when solution in debug mode also fails to complete the operation
|
|
|
|
|
|
Also I'm assuming you're using System.Diagnostics.Process.Start instead of ShellExecute, right?
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
This is my code:
-----------------------------------------
Process commandPrompt = new Process();
commandPrompt.StartInfo.FileName = "C:\\Windows\\System32\\cmd.exe";
//commandPrompt.StartInfo.Arguments = command;
commandPrompt.StartInfo.UseShellExecute = false;
commandPrompt.StartInfo.RedirectStandardInput = true;
commandPrompt.Start();
commandPrompt.StandardInput.WriteLine(command);
-----------------------------------------
I am trying your suggestions - thanks
|
|
|
|
|
Hello,
Is it possible to easily swap values of primary key column between two rows of one DataTable object? I've been trying it like this;
<br />
DataRow dr1=dt.Rows.Find(5);
DataRow dr2=dt.Rows.Find(10);<br />
dr1.BeginEdit();<br />
dr2.BeginEdit();<br />
dr1["item_Id"]=10;<br />
dr2["item_Id"]=5;<br />
dr1.EndEdit();
dr2.EndEdit();<br />
Same thing happens with dt.AcceptChanges();
Is there a way how to achieve this? Any clues are highly appreciated!
Rado
|
|
|
|
|
DataRow dr1=dt.Rows.Find(5);
DataRow dr2=dt.Rows.Find(10);
dr1.BeginEdit();
dr1["item_Id"]=-1;
dr1.EndEdit();
dr2.BeginEdit();
dr2["item_Id"]=5;
dr2.EndEdit();
dr1.BeginEdit();
dr1["item_Id"]=10;
dr2.EndEdit();
dt.AcceptChanges();
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
Oh thanks a lot! How come this didn't come to my mind
Rado
|
|
|
|
|
Because it's common sometimes to overlook the easy stuff in search of the more complex solution. We all do it
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
(Repeated from our private email so that others searching for this answer will find it.)
Hi Rado,
Ever have one of those problem that just eats at you? Well your situation has bugged me for some time because I just knew there had to be an easier, more elegant way. There is......
The problem was that BeginEdit calls for the two DataRow objects were disabling the constraints for the respective rows, but once you called EndEdit for one DataRow , the primary key value for that first row conflicted with the (not yet committed) second DataRow object. Therefore, I had to assume that there was a higher level way of turning off constraints - either the DataRowCollection or the DataTable . Finally, I found the DataTable::BeginLoadData and DataTable::EndLoadData method, which turn off and on, respectively, constraint checking and index maintenance for the entire table.
<br />
table.BeginLoadData();<br />
<font color=green>
table.EndLoadData();<br />
Note: You mentioned the fact that someone suggested turning constraints off for the entire DataSet . As this technicall will work, using BeginLoadData and EndLoadData will affect only one table instead of all the tables for a given DataSet .
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|