473,545 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DirectX creating problem with TimeSpan structure

I am facing problem with TimeSpan structure when DirectX is used.
Following is the sample code that causes the problem:

*************** *************** *************** *************** *************** *************** *************** ******
{
............... ............
PrintTimeSpanPr oblem();
device = new Device(0, DeviceType.Hard ware, this,
CreateFlags.Sof twareVertexProc essing, presentParams);
PrintTimeSpanPr oblem();
..............
}

public void TimeSpanProblem ()
{
DateTime dt1970 = new DateTime(1970, 1, 1);
TimeSpan tss = DateTime.Now - dt1970;
uint nT11 = (uint)(tss.Tick s / TimeSpan.TicksP erSecond);
uint nT1 = (uint)tss.Total Seconds;
uint nT2 = (uint)(tss.Tick s - (nT1 * TimeSpan.TicksP erSecond));
//Ideally nT11 and nT1 should be the same.
//After new Device is created, TimeSpan.TotalS econds does not give
correct value.
if (nT1 != nT11)
{

Debug.WriteLine ("************* *************** *************** *************"
+ "\nPROBLEM! !"
+
"\n************ *************** *************** **************"
+ "\nTicks =" + tss.Ticks.ToStr ing()
+ "\nTotalSeconds (T1) =" + nT1
+ "\nT2 =" + nT2
+ "\nTicks/TicksPerSecond( T11)=" + nT11
+
"\n~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~" );
}
else
{

Debug.WriteLine ("************* *************** *************** *************"
+ "\nEverythi ng OK!!"
+
"\n************ *************** *************** **************"
+ "\nTicks =" + tss.Ticks.ToStr ing()
+ "\nTotalSeconds (T1) =" + nT1
+ "\nT2 =" + nT2
+ "\nTicks/TicksPerSecond( T11)=" + nT11
+
"\n~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~" );
}
}

*************** *************** *************** *************** *************** *************** *************** ******

In normal case (i.e. when TimeSpan behaves correctly), following would
be the output:
ts.Ticks =11792483786198 544
nT1 =1179248378
nT2 =6198544
nT11 =1179248378

Note that, nT1 is first 10 digits of ts.Ticks, and nT2 is last 7
digits of ts.Ticks
After new Device(..) is getting called the output is following:
ts.Ticks =11792499480265 504
nT1 =1179249920
nT2 =280265504
nT11 =1179249948

Note that, nT1 is not same as first 10 digits of ts.Ticks, and nT2 is
9 digits long and is not same as last 7 digits of ts.Ticks
THIS MEANS THAT VALUE OF ts.TotalSeconds DOES NOT CORRESPOND TO THE
VALUE OF ts.Ticks.
Please let me know if anyone of you have faced such a problem?

Regards,
Vibhesh.

May 16 '07 #1
5 1984
On Wed, 16 May 2007 09:54:07 -0700, Vibhesh <vi*****@gmail. comwrote:
[...]
Note that, nT1 is not same as first 10 digits of ts.Ticks, and nT2 is
9 digits long and is not same as last 7 digits of ts.Ticks
THIS MEANS THAT VALUE OF ts.TotalSeconds DOES NOT CORRESPOND TO THE
VALUE OF ts.Ticks.
Well, first of all, keep in mind that you are treating the fractional part
of the number as if it were an actual number. But it's not. It's just
the numerator of a fraction. The digit count will depend on how large the
numerator is, and leading zeros that can be seen in the original Ticks
value will be lost when you treat the numerator as a plain integer and
print it out that way.

As for the difference in the seconds portion, I don't really know. You
didn't offer a concise sample that would allow anyone to reproduce your
results, so it's not possible to examine the situation you have. I don't
see any reason that the act of calling any DirectX function would affect
the calculations you're doing.

Assuming the code you've posted is indeed the code you're using, it would
seem impossible to have the results you've claimed. In particular, I see
no reason that getting the TotalSeconds property from the TimeSpan value
would produce different results from calculating it based on the Ticks and
TicksPerSecond properties.

Note that in your "problemati c" output, the only real problem is that the
value nT1 is calculated incorrectly. Given its value, the result for nT2
is correct, and of course the value for nT11 is correct given the Ticks
value being shown.

So, if I had to guess, I'd say that you have somehow gotten the wrong
value for tss.TotalSecond s for some reason. I doubt there's a problem
with the class itself, so that suggests you've done something wrong in
your own code. Whether that's using a different TimeSpan value to obtain
that property than you use elsewhere, or something more subtle like an
unprotected multi-threaded access to the value, I can't say. You didn't
post any code that shows what you're actually doing (that is, that is a
complete-but-concise example that reliably reproduces the problem), so
there's no way to comment on what you might be doing wrong.

Pete
May 16 '07 #2
Here is a sample code that demonstrates the problem.
To build and run this code you will require DirectX SDK installed on
your system.

Follow the steps below to reproduce the problem.
1.) Create a new Windows Application project in Visual Studio 2003
(the code will also work in 2005)
2.) Open the default Form1 in 'Code View'
3.) Replace the code of Form1 with the code specified below
4.) Add references to DirectX, Direct3D, and Direct3DX dlls.
5.) Run the App
6.) Press TestTimeSpan button to see the output from TimeSpan
structure and my calculations.
7.) Press Create Device button to create a new DirectX device object.
8.) Again press TestTimeSpan button
HERE YOU WILL SEE THE PROBLEM IN THE TIMESPAN STRUCTURE.
NOTICE THE DIFFRENCE BETWEEN Ticks and TotalSeconds properties.
*************** **************C ODE
(form1.cs)***** *************** ********
using System;
using System.Drawing;
using System.Collecti ons;
using System.Componen tModel;
using System.Windows. Forms;
using System.Data;
using Microsoft.Direc tX;
using Microsoft.Direc tX.Direct3D;
using Direct3D = Microsoft.Direc tX.Direct3D;
using System.Diagnost ics;

namespace TestNamespace
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows. Forms.Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.Componen tModel.Containe r components = null;
private System.Windows. Forms.Button btn_TestTimeSpa n;
private System.Windows. Forms.Button btnCreateDevice ;
private System.Windows. Forms.Button btnDisposeDevic e;
private System.Windows. Forms.TextBox txtOutput;
private Device device = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeCompo nent();

}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Disp ose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.btn_TestTi meSpan = new System.Windows. Forms.Button();
this.btnCreateD evice = new System.Windows. Forms.Button();
this.btnDispose Device = new System.Windows. Forms.Button();
this.txtOutput = new System.Windows. Forms.TextBox() ;
this.SuspendLay out();
//
// btn_TestTimeSpa n
//
this.btn_TestTi meSpan.Location = new System.Drawing. Point(0,
48);
this.btn_TestTi meSpan.Name = "btn_TestTimeSp an";
this.btn_TestTi meSpan.Size = new System.Drawing. Size(104,
32);
this.btn_TestTi meSpan.TabIndex = 0;
this.btn_TestTi meSpan.Text = "Test TimeSpan";
this.btn_TestTi meSpan.Click += new
System.EventHan dler(this.btn_T estTimeSpan_Cli ck);
//
// btnCreateDevice
//
this.btnCreateD evice.Location = new System.Drawing. Point(0,
8);
this.btnCreateD evice.Name = "btnCreateDevic e";
this.btnCreateD evice.Size = new System.Drawing. Size(104, 32);
this.btnCreateD evice.TabIndex = 1;
this.btnCreateD evice.Text = "Create Device";
this.btnCreateD evice.Click += new
System.EventHan dler(this.btnCr eateDevice_Clic k);
//
// btnDisposeDevic e
//
this.btnDispose Device.Location = new
System.Drawing. Point(112, 8);
this.btnDispose Device.Name = "btnDisposeDevi ce";
this.btnDispose Device.Size = new System.Drawing. Size(104,
32);
this.btnDispose Device.TabIndex = 2;
this.btnDispose Device.Text = "Dispose Device";
this.btnDispose Device.Click += new
System.EventHan dler(this.btnDi sposeDevice_Cli ck);
//
// txtOutput
//
this.txtOutput. Location = new System.Drawing. Point(8, 96);
this.txtOutput. Multiline = true;
this.txtOutput. Name = "txtOutput" ;
this.txtOutput. ScrollBars =
System.Windows. Forms.ScrollBar s.Both;
this.txtOutput. Size = new System.Drawing. Size(656, 408);
this.txtOutput. TabIndex = 3;
this.txtOutput. Text = "";
//
// Form1
//
this.AutoScaleB aseSize = new System.Drawing. Size(5, 13);
this.ClientSize = new System.Drawing. Size(672, 518);
this.Controls.A dd(this.txtOutp ut);
this.Controls.A dd(this.btnDisp oseDevice);
this.Controls.A dd(this.btnCrea teDevice);
this.Controls.A dd(this.btn_Tes tTimeSpan);
this.FormBorder Style =
System.Windows. Forms.FormBorde rStyle.SizableT oolWindow;
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayo ut(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
try
{
using (Form1 frm = new Form1())
{
frm.Show();
Application.Run (frm);
}
}
catch (Exception e)
{
System.Windows. Forms.MessageBo x.Show("Problem in
application, will now exit. " + e.Message);
}
}

private void CreateDevice()
{
PresentParamete rs presentParams = new PresentParamete rs();
presentParams.W indowed = true;
presentParams.S wapEffect = SwapEffect.Disc ard;
presentParams.A utoDepthStencil Format = DepthFormat.D16 ;
presentParams.E nableAutoDepthS tencil = true;

device = new Device(0, DeviceType.Hard ware, this,
CreateFlags.Sof twareVertexProc essing, presentParams);
}
private void DisposeDevice()
{
device.Dispose( );
}
public void TimeSpanProblem (string strFrom)
{
DateTime dt1970 = new DateTime(1970, 1, 1);
//LoadVC();
System.TimeSpan tss = DateTime.Now - dt1970;
uint nT11 = (uint)(tss.Tick s / TimeSpan.TicksP erSecond);
uint nT1 = (uint)tss.Total Seconds;
uint nT2 = (uint)(tss.Tick s - (nT1 *
TimeSpan.TicksP erSecond));
string displayStr = "@@@@@@@@@"+str From+"@@@@@@@@@ ";
if (nT1 != nT11)
{
displayStr += Environment.New Line +
"************** *************** *************** ************"
+ Environment.New Line + "PROBLEM!! T1 != T11 (NOTICE
THAT THE DECIMALS ARE GONE FOR TotalSeconds)"
+ Environment.New Line +
"************** *************** *************** ************";
}
else
{
displayStr += Environment.New Line +
"************** *************** *************** ************"
+ Environment.New Line + "Everything OK!!"
+ Environment.New Line +
"************** *************** *************** ************";
}

displayStr+=
Environment.New Line + "------TimeSpan---------"
+ Environment.New Line + "tss.Ticks
=
{0}"
+ Environment.New Line + "tss.TotalSecon ds
=
{1}"
+ Environment.New Line + "------My Variables---------"
+ Environment.New Line + "T1 = (uint)tss.Total Seconds
= {2}"
+ Environment.New Line + "T2 = (uint)(tss.Tick s - (nT1
* TimeSpan.TicksP erSecond)) = {3}"
+ Environment.New Line + "T11 = (uint)(tss.Tick s /
TimeSpan.TicksP erSecond) = {4}"
+ Environment.New Line +
"~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~"+E nvironment.NewL ine
+Environment.Ne wLine+Environme nt.NewLine;

txtOutput.Text +=
String.Format(d isplayStr,tss.T icks,tss.TotalS econds,nT1,nT2, nT11);
txtOutput.Selec t(txtOutput.Tex t.Length-2,1);
txtOutput.Scrol lToCaret();
}

private void btn_TestTimeSpa n_Click(object sender,
System.EventArg s e)
{
this.TimeSpanPr oblem("From btn_TestTimeSpa n_Click");
}

private void btnCreateDevice _Click(object sender,
System.EventArg s e)
{
CreateDevice();
}

private void btnDisposeDevic e_Click(object sender,
System.EventArg s e)
{
DisposeDevice() ;
}

}
}

*************** **************C ODE
END************ *************** *******
May 17 '07 #3

Vibhesh wrote:
I am facing problem with TimeSpan structure when DirectX is used.
Following is the sample code that causes the problem:

*************** *************** *************** *************** *************** *************** *************** ******
{
............... ...........
PrintTimeSpanPr oblem();
device = new Device(0, DeviceType.Hard ware, this,
CreateFlags.Sof twareVertexProc essing, presentParams);
PrintTimeSpanPr oblem();
.............
}

public void TimeSpanProblem ()
{
DateTime dt1970 = new DateTime(1970, 1, 1);
TimeSpan tss = DateTime.Now - dt1970;
uint nT11 = (uint)(tss.Tick s / TimeSpan.TicksP erSecond);
uint nT1 = (uint)tss.Total Seconds;
uint nT2 = (uint)(tss.Tick s - (nT1 * TimeSpan.TicksP erSecond));
//Ideally nT11 and nT1 should be the same.
//After new Device is created, TimeSpan.TotalS econds does not give
correct value.
if (nT1 != nT11)
{

Debug.WriteLine ("************* *************** *************** *************"
+ "\nPROBLEM! !"
+
"\n************ *************** *************** **************"
+ "\nTicks =" + tss.Ticks.ToStr ing()
+ "\nTotalSeconds (T1) =" + nT1
+ "\nT2 =" + nT2
+ "\nTicks/TicksPerSecond( T11)=" + nT11
+
"\n~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~" );
}
else
{

Debug.WriteLine ("************* *************** *************** *************"
+ "\nEverythi ng OK!!"
+
"\n************ *************** *************** **************"
+ "\nTicks =" + tss.Ticks.ToStr ing()
+ "\nTotalSeconds (T1) =" + nT1
+ "\nT2 =" + nT2
+ "\nTicks/TicksPerSecond( T11)=" + nT11
+
"\n~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~" );
}
}

*************** *************** *************** *************** *************** *************** *************** ******

In normal case (i.e. when TimeSpan behaves correctly), following would
be the output:
ts.Ticks =11792483786198 544
nT1 =1179248378
nT2 =6198544
nT11 =1179248378

Note that, nT1 is first 10 digits of ts.Ticks, and nT2 is last 7
digits of ts.Ticks
After new Device(..) is getting called the output is following:
ts.Ticks =11792499480265 504
nT1 =1179249920
nT2 =280265504
nT11 =1179249948

Note that, nT1 is not same as first 10 digits of ts.Ticks, and nT2 is
9 digits long and is not same as last 7 digits of ts.Ticks
THIS MEANS THAT VALUE OF ts.TotalSeconds DOES NOT CORRESPOND TO THE
VALUE OF ts.Ticks.
Please let me know if anyone of you have faced such a problem?

Regards,
Vibhesh.
May 17 '07 #4
On Thu, 17 May 2007 09:49:22 -0700, Vibhesh <vi*****@gmail. comwrote:
Here is a sample code that demonstrates the problem.
To build and run this code you will require DirectX SDK installed on
your system. [...]
Huh. Well, I can confirm your problem. The exact same results occur on
my computer with your code.

But I have no good answer. Please note that you will probably have to
report this to Microsoft customer support (use the online form, there
should be no charge since it seems clear it's a bug in their own
software), and you may get a suitable resolution from them.

You might be able to learn more by stepping into the TotalSeconds property
getter (I haven't tried this, but it seems to me that if you are viewing
disassembly while you are debugging, you should be able to step into the
code) and seeing what it's doing. I would think it would just do the same
"divide by TicksPerSecond" that you do in your own example code, but
obviously it's not as simple as that.

In the meantime, since doing the conversion yourself directly is easy and
does work, it seems to me that's a perfectly suitable workaround.

Pete
May 18 '07 #5
"Vibhesh" <vi*****@gmail. comwrote in message
news:11******** **************@ o5g2000hsb.goog legroups.com...
Here is a sample code that demonstrates the problem.
To build and run this code you will require DirectX SDK installed on
your system.

Follow the steps below to reproduce the problem.
1.) Create a new Windows Application project in Visual Studio 2003
(the code will also work in 2005)
2.) Open the default Form1 in 'Code View'
3.) Replace the code of Form1 with the code specified below
4.) Add references to DirectX, Direct3D, and Direct3DX dlls.
5.) Run the App
6.) Press TestTimeSpan button to see the output from TimeSpan
structure and my calculations.
7.) Press Create Device button to create a new DirectX device object.
8.) Again press TestTimeSpan button
HERE YOU WILL SEE THE PROBLEM IN THE TIMESPAN STRUCTURE.
NOTICE THE DIFFRENCE BETWEEN Ticks and TotalSeconds properties.
*************** **************C ODE
(form1.cs)***** *************** ********
using System;
using System.Drawing;
using System.Collecti ons;
using System.Componen tModel;
using System.Windows. Forms;
using System.Data;
using Microsoft.Direc tX;
using Microsoft.Direc tX.Direct3D;
using Direct3D = Microsoft.Direc tX.Direct3D;
using System.Diagnost ics;

namespace TestNamespace
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows. Forms.Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.Componen tModel.Containe r components = null;
private System.Windows. Forms.Button btn_TestTimeSpa n;
private System.Windows. Forms.Button btnCreateDevice ;
private System.Windows. Forms.Button btnDisposeDevic e;
private System.Windows. Forms.TextBox txtOutput;
private Device device = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeCompo nent();

}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Disp ose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.btn_TestTi meSpan = new System.Windows. Forms.Button();
this.btnCreateD evice = new System.Windows. Forms.Button();
this.btnDispose Device = new System.Windows. Forms.Button();
this.txtOutput = new System.Windows. Forms.TextBox() ;
this.SuspendLay out();
//
// btn_TestTimeSpa n
//
this.btn_TestTi meSpan.Location = new System.Drawing. Point(0,
48);
this.btn_TestTi meSpan.Name = "btn_TestTimeSp an";
this.btn_TestTi meSpan.Size = new System.Drawing. Size(104,
32);
this.btn_TestTi meSpan.TabIndex = 0;
this.btn_TestTi meSpan.Text = "Test TimeSpan";
this.btn_TestTi meSpan.Click += new
System.EventHan dler(this.btn_T estTimeSpan_Cli ck);
//
// btnCreateDevice
//
this.btnCreateD evice.Location = new System.Drawing. Point(0,
8);
this.btnCreateD evice.Name = "btnCreateDevic e";
this.btnCreateD evice.Size = new System.Drawing. Size(104, 32);
this.btnCreateD evice.TabIndex = 1;
this.btnCreateD evice.Text = "Create Device";
this.btnCreateD evice.Click += new
System.EventHan dler(this.btnCr eateDevice_Clic k);
//
// btnDisposeDevic e
//
this.btnDispose Device.Location = new
System.Drawing. Point(112, 8);
this.btnDispose Device.Name = "btnDisposeDevi ce";
this.btnDispose Device.Size = new System.Drawing. Size(104,
32);
this.btnDispose Device.TabIndex = 2;
this.btnDispose Device.Text = "Dispose Device";
this.btnDispose Device.Click += new
System.EventHan dler(this.btnDi sposeDevice_Cli ck);
//
// txtOutput
//
this.txtOutput. Location = new System.Drawing. Point(8, 96);
this.txtOutput. Multiline = true;
this.txtOutput. Name = "txtOutput" ;
this.txtOutput. ScrollBars =
System.Windows. Forms.ScrollBar s.Both;
this.txtOutput. Size = new System.Drawing. Size(656, 408);
this.txtOutput. TabIndex = 3;
this.txtOutput. Text = "";
//
// Form1
//
this.AutoScaleB aseSize = new System.Drawing. Size(5, 13);
this.ClientSize = new System.Drawing. Size(672, 518);
this.Controls.A dd(this.txtOutp ut);
this.Controls.A dd(this.btnDisp oseDevice);
this.Controls.A dd(this.btnCrea teDevice);
this.Controls.A dd(this.btn_Tes tTimeSpan);
this.FormBorder Style =
System.Windows. Forms.FormBorde rStyle.SizableT oolWindow;
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayo ut(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
try
{
using (Form1 frm = new Form1())
{
frm.Show();
Application.Run (frm);
}
}
catch (Exception e)
{
System.Windows. Forms.MessageBo x.Show("Problem in
application, will now exit. " + e.Message);
}
}

private void CreateDevice()
{
PresentParamete rs presentParams = new PresentParamete rs();
presentParams.W indowed = true;
presentParams.S wapEffect = SwapEffect.Disc ard;
presentParams.A utoDepthStencil Format = DepthFormat.D16 ;
presentParams.E nableAutoDepthS tencil = true;

device = new Device(0, DeviceType.Hard ware, this,
CreateFlags.Sof twareVertexProc essing, presentParams);
}
private void DisposeDevice()
{
device.Dispose( );
}
public void TimeSpanProblem (string strFrom)
{
DateTime dt1970 = new DateTime(1970, 1, 1);
//LoadVC();
System.TimeSpan tss = DateTime.Now - dt1970;
uint nT11 = (uint)(tss.Tick s / TimeSpan.TicksP erSecond);
uint nT1 = (uint)tss.Total Seconds;
uint nT2 = (uint)(tss.Tick s - (nT1 *
TimeSpan.TicksP erSecond));
string displayStr = "@@@@@@@@@"+str From+"@@@@@@@@@ ";
if (nT1 != nT11)
{
displayStr += Environment.New Line +
"************** *************** *************** ************"
+ Environment.New Line + "PROBLEM!! T1 != T11 (NOTICE
THAT THE DECIMALS ARE GONE FOR TotalSeconds)"
+ Environment.New Line +
"************** *************** *************** ************";
}
else
{
displayStr += Environment.New Line +
"************** *************** *************** ************"
+ Environment.New Line + "Everything OK!!"
+ Environment.New Line +
"************** *************** *************** ************";
}

displayStr+=
Environment.New Line + "------TimeSpan---------"
+ Environment.New Line + "tss.Ticks
=
{0}"
+ Environment.New Line + "tss.TotalSecon ds
=
{1}"
+ Environment.New Line + "------My Variables---------"
+ Environment.New Line + "T1 = (uint)tss.Total Seconds
= {2}"
+ Environment.New Line + "T2 = (uint)(tss.Tick s - (nT1
* TimeSpan.TicksP erSecond)) = {3}"
+ Environment.New Line + "T11 = (uint)(tss.Tick s /
TimeSpan.TicksP erSecond) = {4}"
+ Environment.New Line +
"~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~"+E nvironment.NewL ine
+Environment.Ne wLine+Environme nt.NewLine;

txtOutput.Text +=
String.Format(d isplayStr,tss.T icks,tss.TotalS econds,nT1,nT2, nT11);
txtOutput.Selec t(txtOutput.Tex t.Length-2,1);
txtOutput.Scrol lToCaret();
}

private void btn_TestTimeSpa n_Click(object sender,
System.EventArg s e)
{
this.TimeSpanPr oblem("From btn_TestTimeSpa n_Click");
}

private void btnCreateDevice _Click(object sender,
System.EventArg s e)
{
CreateDevice();
}

private void btnDisposeDevic e_Click(object sender,
System.EventArg s e)
{
DisposeDevice() ;
}

}
}

*************** **************C ODE
END************ *************** *******



I can confirm the issue. The problem is with DirectX resetting the X87
control word, more precisely, the CLR initially sets the FPU to double
precision mode (FCW = 27Fh), however, when DX initializes, it switches the
FPU to single precision mode by resetting the FCW to 7Fh.
The result is that TotalSeconds returns a wrong value, as this routine
expects the FPU to be in double precision mode. The point is who to blame?
DX or the CLR? I would suggest you to do as Peter said, file a bug. In the
mean time I would stay away from the TimeSpan class and use the StopWatch
class.

Willy.


Willy.

May 18 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
10340
by: Dr Paul A Daniels | last post by:
I've got Visual Studio 7.0.9466 and have installed the Framework 1.1 and its SDK and DirectX 9.0 (Summer 2003 release) SDK. OS is Windows XP Pro. I'm logged on with Administrator rights. I can't open the DirectX Summer release sample Direct3D tutorial solutions as I get an error saying that my VS version is too early. However, if I do a...
1
1450
by: Robert Ludewig | last post by:
Hello, I recently started to develop my own little high level, easy to use 3D API on top of managed directx for .net. The idea behind it is having a generic API that lets me create (simpler) 3D-applications in the shortest possible time in .net. It involves implementing things like a node structure for the scenegraph, a console, device...
3
1463
by: johnb41 | last post by:
I am building a .net app that does some simple image tasks (Tiff files): viewing Tiff, viewing thumbnails from multipage tiff, rotation, page (frame) deletion, etc. The problem is that it is so frustratingly slow. Creating and viewing thumbnails for a 50-page tiff (scan of text document) takes about 40 seconds. Commercial image viewers...
3
6266
by: John Hann | last post by:
Hi, A friend of mine is in the process of building a 3d game engine using native DirectX in C++. I would like to contribute to the development of an editor for this engine, but I would prefer to develop it in C#. We've discussed the possibility of creating a COM-based interface to the engine that the editor could use from C#, and I think...
1
1462
by: Piotrek Alchemik | last post by:
Hi, i'm looking somewhere, somehow for samples of directx for modelling group of objects. I can't find any examples, which would help me creating anything like this. If somebody can help me i'd be very greatfull. Best regards Piotrek
14
2635
by: Jessica Weiner | last post by:
I am writing an application in C# which need to plot graphs and simple shapes (polygons, circles, squares etc). Which library is better for this purpose and why? Thanks.
1
2255
by: A. Gaubatz | last post by:
I am using some code that I somewhat cannibalized from a tutorial, and whenever I try to put in an image not of specific seemingly random sizes, it stretches them out alot. The module that runs the code I am using is this: (note that the tutorial had a 3D segment as well, which has been remarked) ...
11
4706
by: parez | last post by:
Hi all, I have a TimeSpan which i get my subtracing a date from a date. TimeSpan ts (Dim ts As TimeSpan) ts = parsedDate.Subtract(DateTime.Now) i get different values for Hours and TotalHours. In my case i was geting -15 and -39. The difference between two is 24 (i know it is obvious).
11
3442
by: raylopez99 | last post by:
I just downloaded the apparently free SDK for DirectX 9, all 200+ MB of it, but as I read about WPF I wonder: is DirectX obsolete? Should I even bother learning how to use it? After all, the end user must have the DirectX library installed on their PC before they can use any video playing program you write. Does WPF even use DirectX? Or...
0
7409
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7664
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7437
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7771
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5343
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4958
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3446
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1900
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
720
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.