|
Abstract & static would be an oxymoron, something cannot be both as an abstract member implies that a derived class will implement. If it were static there would be no derived class.
Im not sure I personally understand what you are trying to achieve.
|
|
|
|
|
Hi all.
I'm trying to read in the date and time from a binary file that was created using mfc. The cTime class was used to create the time stamp. I'm using a TimeSpan object and a DateTime object in order to get the date and time that was saved in the binary file. i.e.
public Count(BinaryReader read)
{
TimeSpan span = TimeSpan.FromSeconds(read.ReadUInt32());
TimeStamp = new DateTime(span.Ticks);
CountNumber = read.ReadUInt32();
}
The date and time returned ends up coming out as 18/02/0035 16:00:01 which is obviously incorrect as this is old data not future data
I looked at the number of ticks returned in span.Ticks compared to the current number of ticks (at roughly 15:22 today)
632460649505030970 - Today
10771200010000000 - Returned from the file.
As you can see there is a big difference and im pretty sure this data is only a year old at the most.
If anyone knows what i'm doing wrong it would be greatly appreciated.
Cheers
Kev
|
|
|
|
|
|
I get the correct date returned when i create a DateTime object with the "Current" number of ticks 632460649505030970 but when i create one with the number of ticks created using the reader i'm getting the date mentioned above, 18/02/0035 16:00:01 which is very wrong.
For some reason the number of ticks that i get returned from span.Ticks must be wrong.
Any ideas anyone??
Kev
|
|
|
|
|
You might want to take a look at this[^].
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
A good article, but it seems to cover everything except what i want. The mfc class being used to store the time is cTime and the article mentions that this class provides an overload for the >> and << operators which are being used to store the time.
The article just doesn't go into any details about how they are overloaded. The time is being saved using the >> (or <<, cant remember :-P) operator and i need to read it into a C# class in such a way as i can get at the date and time. I thought, as did leppy from his comments, that what i did would work but it doesn't so i assume that cTime stores the dateTime in a different format.
If anyone knows how to do this it would be great. I dont need to know why it doesn't work i just need a way to read the cTime data, that has been stored using the >> operator, into a DateTime class in C#.
Cheers
Kev
|
|
|
|
|
The point is that cTime stored the numebr of seconds since Jan 1, 1970 12:00am and the .NET Framework epoch is Jan 1, 0001 12:00am and stores the number of 100 nanosecond intervals since then. You'll have to do a little bit of math to convert the number of seconds to the number of ticks, then use that to create a DateTime object out of the result.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
OK, so the number im reading in was stored based on seconds since 1970 but the Dot Net framework's times are based on 100 nanoseconds since 0001??
Kev
|
|
|
|
|
Is it possible to lower the priority of a program compiled in C# at compile time. I have a program that encodes wav files to wma files as the wav files are generated. It works well, but, it sucks up 100% of the CPU when it runs. Microsoft says the the program will give the processor up automatically as other processes need it, but, I would rather have just run slower anyway. The encoding does not need to be don in real time.
Thanks
|
|
|
|
|
Set the priority for the the current thread as follows.
System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.BelowNormal;
The fields in the ThreadPriority enum are:
<br />
AboveNormal<br />
BelowNormal<br />
Highest<br />
Lowest<br />
Normal<br />
|
|
|
|
|
Thank you very much.
Does that go inside the thread that I spun off or inside the function that calls the thread.
|
|
|
|
|
It doesn't matter where it goes. Every thread exposes the Priority property. It can go in the thread you whose priority you want to lower. It can also be used by another thread (i.e. a parent thread). All you need is a reference to a thread and you can set its priority. If you use the CurrentThread line of code I posted then it needs to be available to (inside) the code that the given thread is running.
|
|
|
|
|
bk5151 wrote:
Is it possible to lower the priority of a program compiled in C# at compile time
I'm not sure what you mean by changing the priority at COMPILE time ?
So I'm going to the assumption you want to change the priority during runtime.
Is your program, multi-threaded ? If so I would guess you could just change the priority of the thread in which your doing your conversion.
|
|
|
|
|
In VC++ 6, I thought there was a way to accomplish this at compile time in the Project Settings menu by optimizing the code. I could have been wrong though. However, at run time will do just fine. Accoustic, showed me a function to call to set this level. I am just not sure if this goes inside the thread that I called or if it goes inside the function that spins the tread off.
|
|
|
|
|
It depends on if your prgram is mult-threaded.
If it is not MT, add Accoustic's code to your program's constructor.
If it is MT, then just change the priority of the thread doing the conversion.
|
|
|
|
|
Thanks guys. I am going to try this out.
|
|
|
|
|
Hello All,
I hope this is a question with a simple solution that I've overlooked. I am loading an image reference (URL) into a ASP.NET image control when the page loads. The problem is that I'm loading a reference from an MLS system and the image link is occasionally broken.
Is there a simple way to reference a property of the image control to tell if the image sucessfully loaded? If so, I can't find it. Currently I'm using code to detect if the URL is valid before setting the property of the image control. This requires a round trip to the image host server to detect a 404 response. It works, but is SLOW when there are more than a dozen pictures. I hate slow...
Any help is appreciated.
Cheers,
Will
|
|
|
|
|
First, this really belongs on the ASP.Net board, but I'll take a whack at it anyway...
I don't know your reasons for caring why/when an image doesn't load, so I'm not sure how useful I can be, but the image loads on the client. You could add attributes to the Image (or HtmlImage) control to execute javascript on a load failure (OnError I think), but that would only work in IE.
In general, could you not just check the image dimensions (still on the client side)? I think the width and height would be zero if the url was not available, and that should work on almost any browser.
Hope this helps.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
can we parse eml file... as in is there any way apart from taking the data as text and getting data out of it by Regular Expression...
|
|
|
|
|
Hi, all.
I'm a bit of a newbie to C# and .NET. I want to create an on-screen keyboard for a touchscreen. They keyboard itself is easy enough, but I'm not sure how to "stuff" the keystrokes into the keyboard buffer. There's probably a better way than "stuffing" to begin with...
I want to be able to pop up a keyboard, and have keystrokes entered into the control that had focus before the keyboard appeared.
Any suggestions, or pointers to useful articles would be appreciated.
Thanks.
Len
|
|
|
|
|
Almost every tochscreen ive ever seen has come with onscreen keyboard software bundled in with them - is there some reason why that or a 3rd party app will not do (ie, is this a leaning excercise?)
|
|
|
|
|
That it a good point. I haven't received the monitor yet, and the product info doesn't say if it comes with a utility to do this. However, having said that, I'm using this in a machine automation application, and would still like to be able to customize the user interface... probably not possible with a third party tool.
So, if anyone knows how to do this, I'm still very interested.
Thanks.
Len
|
|
|
|
|
Can anyone please help me to use Highlighter.net.
my requirement is as follows:
when i click on the filename which is in a listbox, the file content should be displayed in a textbox, and the search words should be highlighted.
|
|
|
|
|
Hi
I got following function. When I debug the code '"+Name+"' is
Name="System.Data.DataRowView".
Does anybody knows why?
private void menuItem1_Select(object sender, System.EventArgs e)
{
string Name = this.listBox1.SelectedItem.ToString();
OleDbConnection conn = new OleDbConnection(connString);
OleDbCommand dbCommand = new OleDbCommand("SELECT Beschreibung FROM tbl_T5 WHERE (Rechner = '"+Name+"')", conn);
conn.Open();
OleDbDataReader dbReader;
dbReader = dbCommand.ExecuteReader();
dbReader.Read();
if (dbReader.HasRows)
{
this.menuItem2.Text = dbReader["Beschreibung"].ToString();
}
dbReader.Close();
conn.Close();
}
|
|
|
|
|
That's quite easy:
Name is set at exactly one location, so the value you see is the result of this.listBox1.SelectedItem.ToString(); .
That means the selected item in your listBox1 is a DataRowView . DataRowView doesn't have an overloaded ToString method, so you simply get the type name.
But what's the question? Obviously you expect Name to be something else. Could it be that you don't want one of listBox1's items?
Without further info we can only guess...
mav
|
|
|
|