|
Unfortunately, there's no inherent concept of atomicity in C#, and no guarantee that you could handle it reliably. The classic example would be to provide some form of undo functionality which you could record your changes in (somehow), and then call this if your code were to fail somehow. While this, initially, might seem to be a viable idea, it's not quite as clear cut as this would indicate. For instance, how would you capture operations going on internally? What happens if those operations introduce side effects?
|
|
|
|
|
I agree. It's too bad. Obviously we are dealing with forcing a sequence of machine instructions to be executed without interrupt. In my days of assembly programming, I was able to suspend interrupts and then resume them by masking by a global interrupt mask bit.
It's too bad that C# doesn't support this. For example, a form like
atomic
{
:
statements
:
}
would have sufficed.
Thanks for your thoughts.
Gus Gustafson
|
|
|
|
|
A static method should at least be thread-safe.
|
|
|
|
|
The question is not thread safety; it's atomicity. The concepts are different.
Thanks for your comment.
Gus Gustafson
|
|
|
|
|
Hi,
Can anyone advise me on how to tell if a Forms icon is set to the default Visual Studio Icon or my own icon.
The reason I ask is that on opening it up into a tabbed document view, I only want to put the form's icon on the generated page tab is it's my own icon, not the VS one. I have everything working except the check to see if it's the default VS one.
Any help most gratefully received.
Thanks.
|
|
|
|
|
..correct me if I'm wrong, but you'll need to access the same property to "check" it as you'll need to "set" it. Wouldn't it be more logical to simply set it?
How would you call/invoke the checking method? Where, what event, and how would the signature look?
There's another problem; it's hard for the computer to compare pictures. As far as it's concerned, they're just a collection of bytes. You could generate a hash-value for the default VS-icon, and compare that to the hash-value generated from the current icon. If the hashes differ, then the icons differ.
Still, it'd be easier to have a single base-form, set the icon in there once, and inherit from there.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi Eddy, thanks for the response.
event as follows...
private void tabbedView1_DocumentAdded(object sender,DevExpress.XtraBars.Docking2010.Views.DocumentEventArgs e)
{
DevExpress.XtraBars.Docking2010.Views.BaseDocument bd = (DevExpress.XtraBars.Docking2010.Views.BaseDocument)e.Document;
if (bd.Form.ShowIcon && bd.Form.Icon.Size == new Size(16, 16)) // Default VS icon is 32x32 //
{
e.Document.Image = bd.Form.Icon.ToBitmap();
}
}
I'm checking the size at the moment to get round the issue as the VS one is 32x32 and any icon I might set on one of my forms is currently 16x16. I can't really go through all my forms too easily to check if I forgot to turn off the VS icon as I have over 400 forms in my project (it's pretty large)...
I only have a handful of forms at the moment where I might set my own icon to make them stand out. It would just be a bit cleaner if I was able to do something like bd.Form.Icon != default.icon etc...
|
|
|
|
|
MarkB123 wrote: It would just be a bit cleaner if I was able to do something like bd.Form.Icon != default.icon etc...
Start here[^]
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks Eddy,
I'll give this a go
|
|
|
|
|
You're welcome
|
|
|
|
|
Hello, please I need help.
How can I fill a datagridview with two datasource?
Yours
|
|
|
|
|
You need to expand your question with more information so we can help you more.
As far as I am aware you can only have one datasource.
Is the information that you want to display in the same format?
Does the data need to be separated?
if the answers are yes to 1. and no to 2. then why not merge the 2 datasources together and then display it?
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
The DGV can only display a single datasource. You'll have to combine the datasets as previously suggested.
Are both coming from the same database? If yes, can you post the SQL-statements that you're trying to load in the grid? Perhaps we can come up with a nice and easy alternative
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
ok, the both comes from the same datagridview.
I want to fill my datagridview from a table "tax" and table "products" of the same database.
Please how can i combine the datasets?
|
|
|
|
|
geralson wrote: Please how can i combine the datasets? You'd combine them on the server; instead of fetching data FROM [tax] and FROM [products], you JOIN them.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
If you're determined not to use the server to do this, you'd have to create a new DataTable that contained the matching results from both sets, or use the techniques outlined here[^].
|
|
|
|
|
converting database schema in form of schema graph having primary and foreign key relationship and storing in cache using datastructure........?????????
|
|
|
|
|
Just throwing question marks at a sentence doesn't make this a question. What are you asking, and what have you written so far?
|
|
|
|
|
Visual Studio has tools where a table can be viewed as a schema diagram - if that is what you are looking for.
|
|
|
|
|
hey guys i'm making a ladder and snake game using C# and i'm stuck at the point where i need to move my players forward .. which means that the players move correctly only in round 1 but after that they start going backwards .
for example for player one the first turn the dice showed number 4 so it moved to square 4 , in second round the dice showed number 2 the player goes back to number two and not to number 6 as it's suppose to .. so can you help me with that i would really appreciate it
this is my code so far :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ladder__snake
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//variables to hold the players locations
int blueposition = 1;
int redposition = 1;
int round = 0;
bool drawbg = false;
Point[] squares = new Point[26];
public void main()
{
//array for the squares
squares[0] = new Point(50, 450);
squares[1] = new Point(150, 450);
squares[2] = new Point(250, 450);
squares[3] = new Point(350, 450);
squares[4] = new Point(450, 450);
squares[5] = new Point(450, 350);
squares[6] = new Point(350, 350);
squares[7] = new Point(250, 350);
squares[8] = new Point(150, 350);
squares[9] = new Point(50, 350);
squares[10] = new Point(50, 250);
squares[11] = new Point(150, 250);
squares[12] = new Point(350, 250);
squares[13] = new Point(350, 250);
squares[14] = new Point(450, 250);
squares[15] = new Point(450, 150);
squares[16] = new Point(350, 150);
squares[17] = new Point(250, 150);
squares[18] = new Point(150, 150);
squares[19] = new Point(50, 150);
squares[20] = new Point(50, 50);
squares[21] = new Point(150, 50);
squares[22] = new Point(250, 50);
squares[23] = new Point(350, 50);
squares[24] = new Point(450, 50);
}
private void button1_Click(object sender, EventArgs e)
{
round++;
label3.Text = round.ToString();
//for the blue player dice
Random rnd;
int guess;
rnd = new Random();
guess = rnd.Next(1, 7);
pictureBox1.Image = Image.FromFile(guess.ToString() + ".png");
// Get the Blue player moving
switch (guess)
{
case 1:
bluePlayer.Location = new Point(50, 450);
break;
case 2:
bluePlayer.Location = new Point(150, 450);
break;
case 3:
bluePlayer.Location = new Point(250, 450);
break;
case 4:
bluePlayer.Location = new Point(250, 350);
MessageBox.Show("It's a ladder move to square 8");
break;
case 5:
bluePlayer.Location = new Point(450, 450);
break;
case 6:
bluePlayer.Location = new Point(450, 350);
break;
}
//bluePlayer.Location = squares[blueposition+guess];
//BluePlayer += guess;
//currentPosition1 += guess;
// bluePlayer.Location = squares[BluePlayer+guess];
//guess = 0;
label4.Visible = false;
label5.Visible = true;
label5.Text = "Red Player's turn";
button2.Enabled = true;
button1.Enabled = false;
pictureBox2.Image = Image.FromFile("dice.png");
//blueposition += guess;
//bluePlayer.Location = squares[guess];
}
private void button2_Click(object sender, EventArgs e)
{
//for the red player dice
Random rnd;
int guess;
rnd = new Random();
guess = rnd.Next(1, 7);
pictureBox2.Image = Image.FromFile(guess.ToString() + ".png");
//redposition += guess;
switch (guess)
{
case 1:
redPlayer.Location = new Point(50, 445);
break;
case 2:
redPlayer.Location = new Point(150, 445);
break;
case 3:
redPlayer.Location = new Point(250, 445);
break;
case 4:
redPlayer.Location = new Point(250, 350);
MessageBox.Show("It's a ladder move to square 8");
break;
case 5:
redPlayer.Location = new Point(450, 445);
break;
case 6:
redPlayer.Location = new Point(450, 345);
break;
}
label5.Visible = false;
label4.Visible = true;
label4.Text = "Blue Player's turn";
button2.Enabled = false;
button1.Enabled = true;
pictureBox1.Image = Image.FromFile("dice.png");
}
private void groupBox2_Enter(object sender, EventArgs e)
{
if (!drawbg)
{ groupBox2.Visible = true; }
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void Form1_Load_1(object sender, EventArgs e)
{
pictureBox1.Image = pictureBox2.Image = Image.FromFile("dice.png");
}
}
}
|
|
|
|
|
Your code needs to be formatted, click on Edit to make changes and then click on the format bar above the edit box and select code, and scroll down the list to select the programming language. Then move all your code inbetween the <pre > tags. </pre>
|
|
|
|
|
this program I am do it but there is an error into it ,the error is in the function ...gotoxy().the massege error is "gotoxy is undeclarated"...I am do this program by Visual Stadiue 2006...
the code:
#include<iostream.h>
class base
{private:
int n,i,j,h,x[10];
float fx[10][10];
static char c;
public:
void set(int cn,int ci,int cj,int ch,int cx,float cfx,char cc)
{
cn=n;ci=i;cj=j;ch=h;cx=x[10];cfx=fx[10][10];cc=c;
}
void show()
{cout<<"\n\t\t******\t THE DIFFREEN\t******";
cout<<"\n\n";
cout<<"\n ENTER THE NUMBER OF THE VALUSE OF X:";
cin>>n;
cout<<"\n\n ENTER THE FIRST VALUE OF X1:";
cin>>x[0];
cout<<"\n ENTER THE INTERVAL:";
cin>>h;
for(i=1;i<n;i++)
x[i]=x[i-1]+h;
cout<<"\n\n\n ENTER THE VALU OF F(X):";
for(i=0;i<n;i++)
{
cout<<"\n f("<<x[i]<<")=";
cin>>fx[i][0];
}
for(i=1;i<n;i++)
for(j=1;j<n-i+1;j++)
fx[j-1][i]=fx[j][i-1]-fx[j-1][i-1];
cout<<"\n\nX\tf(x)\t";
for(i=1;i<n;i++)
cout<<c<<i<<"f(x)\t";
cout<<"\n";
for(i=0;i<n;i++)
{gotoxy(3,i*3+4);
cout<<x[i];}
for(j=0;j<n-i;j++)
if(i+j<n)
{
gotoxy((i+1)*9,((j*3)+i+4));
cout<<fx[j][i];
}}
};
void main()
{base k;
k.show();
}
char base::c=30;
|
|
|
|
|
There are lots of mistakes.
for () {
and };
but fixing these won't make the other errors go away.
Your biggest problems are text layout. indent (3 or 4 spaces from the left edge)
for () {
doSomething();
a = b+c;
};
it helps if you create both open{ and closing braces }; at the same time and insert code between.
modified 15-May-13 15:57pm.
|
|
|
|
|
1) That's not C#, so you are in the incorrect forum
2) I don't think VC++ has any gotoxy(int, int) method in the libraries so you will probably need to make your own, see this:
http://www.cplusplus.com/forum/beginner/28859/[^]
If you think you can do a thing or think you can't do a thing, you're right - Henry Ford
Emmanuel Medina Lopez
|
|
|
|
|
Either you havent created a method call "gotoxy()" or you haven't included a library file (.h or .cpp) that contains the "gotoxy()" method.
Think! Don't write a line of code unless you absolutely need to.
|
|
|
|
|