|
what is the difference b/w Control and Literal?
Also what is a literal control?
THanks
|
|
|
|
|
Is this ASP.NET ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Control is the base class for all web controls. A Literal is a control that will just render as the text that you put in the Text property.
<asp:Literal Runat="server" Text="asdf" />
will simply render as:
asdf
---
b { font-weight: normal; }
|
|
|
|
|
How do I set a window be topmost to only one window handle instead of all windows. Tried using SetWindowPos the hwndInserAfter does not work properly. Any help will be appreciated.
|
|
|
|
|
Make the window that you want your window to be on top of the parent of that window. So if Form1 creates Form2 and sets the Form1 instance to be the parent of the Form2 instance, it will always be above the Form1 instance, as you'd expect from a child dialog.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I just tried win32 setparent method it works. Can someone validate if this is ok.
|
|
|
|
|
Your Form has a Parent property, you don't need to do anything with Win32.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
The child window is on a separate background thread. If I set the parent property I am getting some exception like "Cannot add top level control". The win32 functions works perfectly. I need this window on the background thread to overlap the main ui thread window. Thereby I can have modal windows which will not block the main thread. We have some legacy applications which are being auto generated into C# code. These apps have lots of modal windows. We have to plug in these apps into a UI framework already deployed. These individual apps will reside on different tabs in the UI framework. When these apps open modal windows we need to be able to other tabs. Hope this explains why we have to run this in a separate thread with its own message loop. Each interaction with the main UI thread will be synchronized via BeginInvoke. There will be minimal interaction with UI thread controls except for getting some static security tokens, cust name etc.
-- modified at 1:11 Wednesday 18th January, 2006
|
|
|
|
|
Careth Jefferson wrote: "Cannot add top level control".
That's a new error - you can use an attribute to get rid of that.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
[DllImport("user32.dll")]
public static extern bool BringWindowToTop(IntPtr hWnd);
public void BringToTop()
{
BringWindowToTop(this.Handle);
}
|
|
|
|
|
Hi Guys:
i would like to know how to do the owner draw for hscrollbar c# 2005?
anyone?
|
|
|
|
|
There's not an OwnerDraw property ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
TripleDES in outer cipher block chaining mode (CBC) without having the needed IV (Initialization Vector) ?
I am trying to write a client program for a server using a strange protocol that isn’t very well documented. I am completely lost here and I don’t know how to do this. Hope someone can enlighten me and help me out here.
The protocol says that I have to encrypt the tcp packages sent from the client to the server using TripleDES in outer cipher block chaining mode with a 14 byte DES key. (The key is known on the server and on the client)
Correct me if I am wrong here. But don’t you need two keys to encrypt a message using TripleDES CBC ? One key and one IV (Initialization Vector).
The documentation doesn’t tell me anything about what IV key the servers uses to decrypt the messages once it is received on the server side so I don’t know what IV key to encrypt the messages with. I know this is VERY vague, but I don’t know how to explain it any better.
Hope anyone can help me out here.
|
|
|
|
|
The initialisation vector (IV) is not a key. It is a sequence of random digits that are applied to the start of the encrypted document. This is because for certain documents there is a well known starting sequence and given the same key, they would all encrypt to the same value, so the first few bytes of the encrypted text of multiple documents using the same key would look the same. Crack one and you have the others. The IV scrambles the start of the document and becuase the encryption of block n+1 depends on how block n was encrypted it becomes exceedingly difficult to determine any repeated sections of the file.
The IV is known and you are free to transmit it in plaintext because even if an attacker gets hold of it they cannot do anything with it without the key. The IV should be different on each communication otherwise similar files will look similar when encrypted.
I don't know if this helps with your problem, but knowing a bit more about the IV may help you track down a solution more easily.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
Thanks, this helped me.
I think my problem is that the protocol isnt very well documented becuase it doesnt say anything on how to generate the iv and how i should tell the server witch IV i used to decrypt the message.
If i encrypt a message with these keys on the client side:
DES KEY: byte[] localDesKey = {01,02,03,04,05,06,07,08,09,10,11,12,13,14};
Randomly generated IV : byte[] myIV = {02,02,03,12};
The server allready know the DES key but would also need the IV to decrypt the message. Am I right ?
The protocol documentation doesnt say anything about how I should tell the server what IV i used.
This is what the protocol documentation is telling me .
<protocol.txt>
Uses encrypted tcp connections to communicate with its cardservers,
for every card a dedicated tcp connection is used.The encryption used is
Triple-DES in outer cipher block chaining mode (CBC)
After opening a TCP connection to the server, the client first receives 14
random bytes. These bytes are to be XORed to the Triple-DES key from the config
file. (.). The result forms the
Triple DES key to be used to send Username and Password to the server, I
call it the login key.
Next the client has to send a packet with cmd = MSG_CLIENT_2_SERVER_LOGIN
including username and password in the data field.
The username is sent as a C-String (NULL terminated), the password
follows directly after the zero termination byte of the username. The
password has to be put through the glibc crypt() function, using salt
$1$abcdefgh$. The password in the data field has to be NULL terminated and the
packet encrypted with the login key.
|
|
|
|
|
jbergetun wrote: The server allready know the DES key but would also need the IV to decrypt the message. Am I right ?
Right. The client and server are both using the same key, but the client generates the IV when it communicates with the server (and vice versa) so it needs some way of communicating the IV to the server.
jbergetun wrote: After opening a TCP connection to the server, the client first receives 14
random bytes.
the random bytes are the IV I'd guess*, there is no other reason for starting the communication with 14 random bytes. The IV is typically XORed into the start of the data stream rather than the key - I'm not sure what the effect would be, it is randomising the key so that the encrypted version of the user name and password being sent is at least different each time it is sent.
* "guess" being the operative word
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
I found some source code for a client programmed in C.
Dont understand much but maybe someone else does.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <rpc des_crypt.h="">
#include <sys socket.h="">
#include <netinet in.h="">
#include <netdb.h>
#define CWS_NETMSGSIZE 240
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;
#define CWS_FIRSTCMDNO 0xe0
typedef enum
{
MSG_CLIENT_2_SERVER_LOGIN = CWS_FIRSTCMDNO,
MSG_CLIENT_2_SERVER_LOGIN_ACK,
MSG_CLIENT_2_SERVER_LOGIN_NAK,
MSG_CARD_DATA_REQ,
MSG_CARD_DATA,
MSG_SERVER_2_CLIENT_NAME,
MSG_SERVER_2_CLIENT_NAME_ACK,
MSG_SERVER_2_CLIENT_NAME_NAK,
MSG_SERVER_2_CLIENT_LOGIN,
MSG_SERVER_2_CLIENT_LOGIN_ACK,
MSG_SERVER_2_CLIENT_LOGIN_NAK,
MSG_ADMIN,
MSG_ADMIN_ACK,
MSG_ADMIN_LOGIN,
MSG_ADMIN_LOGIN_ACK,
MSG_ADMIN_LOGIN_NAK,
MSG_ADMIN_COMMAND,
MSG_ADMIN_COMMAND_ACK,
MSG_ADMIN_COMMAND_NAK,
MSG_KEEPALIVE = CWS_FIRSTCMDNO + 0x1d
} net_msg_type_t;
typedef enum
{
COMMTYPE_CLIENT,
COMMTYPE_SERVER
} comm_type_t;
typedef struct customData_struct
{
uint16 sid;
} customData_t;
void des_key_parity_adjust(uint8 *key, uint8 len)
{
uint8 i, j, parity;
for (i = 0; i < len; i++)
{
parity = 1;
for (j = 1; j < 8; j++) if ((key[i] >> j) & 0x1) parity = ~parity & 0x01;
key[i] |= parity;
}
}
uint8 *des_key_spread(uint8 *normal)
{
static uint8 spread[16];
spread[ 0] = normal[ 0] & 0xfe;
spread[ 1] = ((normal[ 0] << 7) | (normal[ 1] >> 1)) & 0xfe;
spread[ 2] = ((normal[ 1] << 6) | (normal[ 2] >> 2)) & 0xfe;
spread[ 3] = ((normal[ 2] << 5) | (normal[ 3] >> 3)) & 0xfe;
spread[ 4] = ((normal[ 3] << 4) | (normal[ 4] >> 4)) & 0xfe;
spread[ 5] = ((normal[ 4] << 3) | (normal[ 5] >> 5)) & 0xfe;
spread[ 6] = ((normal[ 5] << 2) | (normal[ 6] >> 6)) & 0xfe;
spread[ 7] = normal[ 6] << 1;
spread[ 8] = normal[ 7] & 0xfe;
spread[ 9] = ((normal[ 7] << 7) | (normal[ 8] >> 1)) & 0xfe;
spread[10] = ((normal[ 8] << 6) | (normal[ 9] >> 2)) & 0xfe;
spread[11] = ((normal[ 9] << 5) | (normal[10] >> 3)) & 0xfe;
spread[12] = ((normal[10] << 4) | (normal[11] >> 4)) & 0xfe;
spread[13] = ((normal[11] << 3) | (normal[12] >> 5)) & 0xfe;
spread[14] = ((normal[12] << 2) | (normal[13] >> 6)) & 0xfe;
spread[15] = normal[13] << 1;
des_key_parity_adjust(spread, 16);
return spread;
}
void des_random_get(uint8 *buffer, uint8 len)
{
uint8 idx = 0;
int randomNo = 0;
for (idx = 0; idx < len; idx++)
{
if (!(idx % 3)) randomNo = rand();
buffer[idx] = (randomNo >> ((idx % 3) << 3)) & 0xff;
}
}
int des_encrypt(uint8 *buffer, int len, uint8 *deskey)
{
uint8 checksum = 0;
uint8 noPadBytes;
uint8 padBytes[7];
char ivec[8];
uint16 i;
if (!deskey) return len;
noPadBytes = (8 - ((len - 1) % 8)) % 8;
if (len + noPadBytes + 1 >= CWS_NETMSGSIZE-8) return -1;
des_random_get(padBytes, noPadBytes);
for (i = 0; i < noPadBytes; i++) buffer[len++] = padBytes[i];
for (i = 2; i < len; i++) checksum ^= buffer[i];
buffer[len++] = checksum;
des_random_get((uint8 *)ivec, 8);
memcpy(buffer+len, ivec, 8);
for (i = 2; i < len; i += 8)
{
cbc_crypt(deskey , (char *) buffer+i, 8, DES_ENCRYPT, ivec);
ecb_crypt(deskey+8, (char *) buffer+i, 8, DES_DECRYPT);
ecb_crypt(deskey , (char *) buffer+i, 8, DES_ENCRYPT);
memcpy(ivec, buffer+i, 8);
}
len += 8;
return len;
}
int des_decrypt(uint8 *buffer, int len, uint8 *deskey)
{
char ivec[8];
char nextIvec[8];
int i;
uint8 checksum = 0;
if (!deskey) return len;
if ((len-2) % 8 || (len-2) < 16) return -1;
len -= 8;
memcpy(nextIvec, buffer+len, 8);
for (i = 2; i < len; i += 8)
{
memcpy(ivec, nextIvec, 8);
memcpy(nextIvec, buffer+i, 8);
ecb_crypt(deskey , (char *) buffer+i, 8, DES_DECRYPT);
ecb_crypt(deskey+8, (char *) buffer+i, 8, DES_ENCRYPT);
cbc_crypt(deskey , (char *) buffer+i, 8, DES_DECRYPT, ivec);
}
for (i = 2; i < len; i++) checksum ^= buffer[i];
if (checksum) return -1;
return len;
}
uint8 *des_login_key_get(uint8 *key1, uint8 *key2)
{
uint8 des14[14];
static uint8 des16[16];
int i;
for (i = 0; i < 14; i++)
{
des14[i] = key1[i] ^ key2[i];
}
memcpy(des16, des_key_spread(des14), 16);
return des16;
}
int network_message_send(int handle, uint16 *netMsgId, customData_t *customData, uint8 *buffer, int len, uint8 *deskey, comm_type_t commType)
{
uint8 netbuf[CWS_NETMSGSIZE];
if (len < 3 || len + 12 > CWS_NETMSGSIZE || handle < 0) return -1;
buffer[1] = (buffer[1] & 0xf0) | (((len - 3) >> 8) & 0x0f);
buffer[2] = (len - 3) & 0xff;
memcpy(netbuf+12, buffer, len);
len += 12;
if (netMsgId) { if (commType == COMMTYPE_CLIENT) (*netMsgId)++; netbuf[2] = (*netMsgId) >> 8; netbuf[3] = (*netMsgId) & 0xff; }
else netbuf[2] = netbuf[3] = 0;
if (customData)
{
netbuf[4] = customData->sid >> 8;
netbuf[5] = customData->sid & 0xff;
memset(netbuf+6, 0, 6);
}
else memset(netbuf+4, 0, 8);
if ((len = des_encrypt(netbuf, len, deskey)) < 0) return -1;
netbuf[0] = (len - 2) >> 8;
netbuf[1] = (len - 2) & 0xff;
write(handle, netbuf, len);
return 0;
}
int network_message_receive(int handle, uint16 *netMsgId, customData_t *customData, uint8 *buffer, uint8 *deskey, comm_type_t commType)
{
int len;
uint8 netbuf[CWS_NETMSGSIZE];
int returnLen;
if (customData) memset(customData, 0, sizeof(customData_t));
if (!buffer || handle < 0) return -1;
len = read(handle, netbuf, 2);
if (!len) return 0;
if (len != 2) return -1;
if (((netbuf[0] << 8) | netbuf[1]) > CWS_NETMSGSIZE - 2) return -1;
len = read(handle, netbuf+2, (netbuf[0] << 8) | netbuf[1]);
if (!len) return 0;
if (len != ((netbuf[0] << 8) | netbuf[1])) return -1;
len += 2;
if ((len = des_decrypt(netbuf, len, deskey)) < 15) return -1;
if ((returnLen = (((netbuf[13] & 0x0f) << 8) | netbuf[14]) + 3) > len-12) return -1;
if (netMsgId)
{
switch (commType)
{
case COMMTYPE_SERVER:
*netMsgId = (netbuf[2] << 8) | netbuf[3];
break;
case COMMTYPE_CLIENT:
if (*netMsgId != ((netbuf[2] << 8) | netbuf[3])) return -1;
break;
default:
return -1;
break;
}
}
if (customData)
{
customData->sid = (netbuf[4] << 8) | netbuf[5];
}
memcpy(buffer, netbuf+12, returnLen);
return returnLen;
}
void network_cmd_no_data_send(int handle, uint16 *netMsgId, customData_t *customData, net_msg_type_t cmd, uint8 *deskey, comm_type_t commType)
{
uint8 buffer[CWS_NETMSGSIZE];
buffer[0] = cmd; buffer[1] = 0;
network_message_send(handle, netMsgId, customData, buffer, 3, deskey, commType);
}
int network_cmd_no_data_receive(int handle, uint16 *netMsgId, customData_t *customData, uint8 *deskey, comm_type_t commType)
{
uint8 buffer[CWS_NETMSGSIZE];
if (network_message_receive(handle, netMsgId, customData, buffer, deskey, commType) != 3) return -1;
return buffer[0];
}
int network_tcp_incoming_port_open(uint16 port)
{
struct sockaddr_in socketAddr;
int socketOptActive = 1;
int handle;
if (!port) return -1;
if ((handle = socket(PF_INET, SOCK_STREAM, 0)) < 0)
{
fprintf(stderr, "network port %u open: ", port);
perror("socket");
return -1;
}
if (setsockopt(handle, SOL_SOCKET, SO_REUSEADDR, &socketOptActive, sizeof(int)) < 0)
{
fprintf(stderr, "network port %u open: error setsockopt\n", port);
close(handle);
return -1;
}
socketAddr.sin_family = AF_INET;
socketAddr.sin_port = htons(port);
socketAddr.sin_addr.s_addr = htonl(INADDR_ANY);
if (bind(handle, (struct sockaddr *) &socketAddr, sizeof (socketAddr)) < 0)
{
fprintf(stderr, "network port %u open: ", port);
perror("bind");
close(handle);
return -1;
}
if (listen(handle, 5) < 0)
{
fprintf(stderr, "network port %u open: ", port);
perror("listen");
close(handle);
return -1;
}
return handle;
}
int network_tcp_connection_accept(int socketHandle)
{
int connHandle;
struct sockaddr_in peerAddr;
struct sockaddr_in myAddr;
socklen_t peerAddrLen;
socklen_t myAddrLen;
uint16 peerPort, myPort;
uint32 peerIp, myIp;
if (socketHandle < 0) return -1;
peerAddrLen = sizeof(peerAddr);
myAddrLen = sizeof(myAddr);
if ((connHandle = accept(socketHandle, (struct sockaddr *) &peerAddr, &peerAddrLen)) < 0) { fprintf(stderr, "error network accept connection\n"); return -1; }
peerPort = ntohs(peerAddr.sin_port);
peerIp = ntohl(peerAddr.sin_addr.s_addr);
myPort = ntohs(myAddr.sin_port);
myIp = ntohl(myAddr.sin_addr.s_addr);
/* optional: do checks on or log IP of incoming connections */
return connHandle;
}
int network_tcp_connection_open(uint8 *hostname, uint16 port)
{
int handle;
struct hostent *hostaddr;
struct sockaddr_in socketAddr;
if (!(hostaddr = gethostbyname(hostname))) { fprintf(stderr, "Host lookup of %s failed\n", hostname); return -1; }
if ((handle = socket(PF_INET, SOCK_STREAM, 0)) < 0) { fprintf(stderr, "network make connection: couldn't create socket\n"); return -1; }
socketAddr.sin_family = AF_INET;
socketAddr.sin_port = htons(port);
socketAddr.sin_addr.s_addr = ((struct in_addr *)hostaddr->h_addr)->s_addr;
if (connect(handle, (struct sockaddr *)&socketAddr, sizeof(socketAddr)) < 0) { fprintf(stderr, "network make connection: error connect\n"); close(handle); return -1; }
return handle;
}
|
|
|
|
|
Hi,
I am working on a project with a WebBrowser, the poblem is I am looping in a function, and then I want the function to wait until the Document finishes loading..
something like this is what I am doing,
HTMLSelectElementClass sEC2 = (HTMLSelectElementClass) myDoc.all.item( "sel", 0 );
for( int x=0; x
|
|
|
|
|
i nead a code that calculating fraction by using operatoroverloading and the LCM and GCD
|
|
|
|
|
Gee - that doesn't sound like homework at all. What have you written so far ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi, Christian Graus i`m realy apperciate your replay and i think that i found the code i need.
using System;
namespace Point_project
{
public class Fraction
{
private int up, down;
public Fraction()
{}
public Fraction( int m, int n)
{
Up = m;
Down = n;
}
public override string ToString()
{
return Up+""+" / "+Down;
}
public int Up
{
get
{
return up;
}
set
{
up = value;
}
}
public int Down
{
get
{
return down;
}
set
{
down = value;
}
}
public static Fraction operator + (Fraction x, Fraction y)
{
int r1 = (x.Down * y.Up) + (y.down * x.Up);
int r2 = x.Down * y.down;
return new Fraction( r1, r2);
}
public static Fraction Add( Fraction x, Fraction y)
{
return x + y;
}
public static Fraction operator - (Fraction x, Fraction y)
{
int r1 = (y.down * x.Up)-(x.Down * y.Up) ;
int r2 = x.Down * y.down;
return new Fraction( r1, r2);
}
public static Fraction Sub( Fraction x, Fraction y)
{
return x - y;
}
public static Fraction operator * (Fraction x, Fraction y)
{
return new Fraction( x.Up * y.Up, x.Down * y.Down);
}
public static Fraction Multiply( Fraction x, Fraction y)
{
return x * y;
}
public static Fraction operator / ( Fraction x, Fraction y)
{
int r1 = x.Up * y.Down;
int r2 = x.Down * y.Up;
return new Fraction( r1, r2);
}
public static Fraction Division ( Fraction x, Fraction y)
{
return x / y;
}
public static int GCD(int left, int right)
{
if (left < 0)
left = - left;
if (right < 0)
right = - right;
if (left < 2 || right < 2)
return 1;
if(left == right)return left;
do
{
if (left < right)
{
int temp = left;
left = right;
right = temp;
}
left %= right;
} while (left != 0);
return right;
}
public void simplify()
{
int g=GCD(down,up);
down/=g;
up/=g;
}
}
public class FractionTeast
{
static void Main()
{
Fraction w = new Fraction();
Fraction x = new Fraction();
Fraction y = new Fraction();
Fraction z = new Fraction();
Console.Write("Numerator1 =");
x.Up = Convert.ToInt32(Console.ReadLine());
Console.Write("denominator1 =");
x.Down = Convert.ToInt32(Console.ReadLine());
while(x.Down == 0)
{
Console.Write("Invalid value REENTER denominator1 =");
x.Down = Convert.ToInt32(Console.ReadLine());
}
Console.Write("\nNumerator2 =");
y.Up = Convert.ToInt32(Console.ReadLine());
Console.Write("denominator2 =");
y.Down = Convert.ToInt32(Console.ReadLine());
while(y.Down == 0)
{
Console.Write("Invalid value REENTER denominator1 =");
y.Down = Convert.ToInt32(Console.ReadLine());
}
Console.Write("\nSelect the calculation type (1:Addtion, 2:Subtraction, 3:Multiplication, 4:Division, Or 0:ToTerminate)==>");
sbyte e = Convert.ToSByte(Console.ReadLine());
while(e != 0)
{
if(e < 0 || e > 4)
{
Console.Write("\nInvalid number PLEASE Select the calculation type (1:Addtion, 2:Subtraction, 3:Multiplication, 4:Division, Or 0:ToTerminate)==>");
e = Convert.ToSByte(Console.ReadLine());
}
if( e == 1)
{
z = (x+y);
z.simplify();
if(z.Down == 1)
{
Console.WriteLine(x.Up+"/"+x.Down+" + "+y.Up+"/"+y.Down+" = "+z.Up);
}
else if(z.Up == 0)
{
Console.WriteLine(x.Up+"/"+x.Down+" + "+y.Up+"/"+y.Down+" = 0");
}
else
{
Console.WriteLine(x.Up+"/"+x.Down+" + "+y.Up+"/"+y.Down+" = "+z);
}
Console.Write("\nSelect the calculation type (1:Addtion, 2:Subtraction, 3:Multiplication, 4:Division, Or 0:ToTerminate)==>");
e = Convert.ToSByte(Console.ReadLine());
}
if( e == 2)
{
z = (x-y);
z.simplify();
if(z.Down == 1)
{
Console.WriteLine(x.Up+"/"+x.Down+" - "+y.Up+"/"+y.Down+" = "+z.Up);
}
else if(z.Up == 0)
{
Console.WriteLine(x.Up+"/"+x.Down+" - "+y.Up+"/"+y.Down+" = 0");
}
else
{
Console.WriteLine(x.Up+"/"+x.Down+" - "+y.Up+"/"+y.Down+" = "+z);
}
Console.Write("\nSelect the calculation type (1:Addtion, 2:Subtraction, 3:Multiplication, 4:Division, Or 0:ToTerminate)==>");
e = Convert.ToSByte(Console.ReadLine());
}
if( e == 3)
{
z = (x*y);
z.simplify();
if(z.Down == 1)
{
Console.WriteLine(x.Up+"/"+x.Down+" X "+y.Up+"/"+y.Down+" = "+z.Up);
}
else if(z.Up == 0)
{
Console.WriteLine(x.Up+"/"+x.Down+" X "+y.Up+"/"+y.Down+" = 0");
}
else
{
Console.WriteLine(x.Up+"/"+x.Down+" X "+y.Up+"/"+y.Down+" = "+z);
}
Console.Write("\nSelect the calculation type (1:Addtion, 2:Subtraction, 3:Multiplication, 4:Division, Or 0:ToTerminate)==>");
e = Convert.ToSByte(Console.ReadLine());
}
if( e == 4)
{
z = (x/y);
z.simplify();
if(z.Down == 1)
{
Console.WriteLine(x.Up+"/"+x.Down+" / "+y.Up+"/"+y.Down+" = "+z.Up);
}
else if(z.Up == 0)
{
Console.WriteLine(x.Up+"/"+x.Down+" / "+y.Up+"/"+y.Down+" = 0");
}
else
{
Console.WriteLine(x.Up+"/"+x.Down+" / "+y.Up+"/"+y.Down+" = "+z);
}
Console.Write("\nSelect the calculation type (1:Addtion, 2:Subtraction, 3:Multiplication, 4:Division, Or 0:ToTerminate)==>");
e = Convert.ToSByte(Console.ReadLine());
}
}
if( e == 0)
{
Console.WriteLine("\nPress ENTER toterminate");
Console.ReadLine();
}
}
}
}
casue i'm the man withno lose
|
|
|
|
|
Looks likely. If you 'found' this code, I recommend you learn what it does, because your professor will ask you and your next homework will assume you know how this one works.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
well, i mean i that found the simplifying methods and matched it together and with the rest of the code even it(simplifying methods) were containing many mistakes and i fix it
but the rest of the code me who made it.
so don`t be ware for me
i made the discussion with my Prof. about it and i was great
but anyway thanks a lot
casue i'm the man withno lose
|
|
|
|
|
Hi!
Currently I'm writing a very simple mail server using SMTP and POP3. My architecture is as follows:
Start Mailserver ->
-> create SMTP server thread
-> create thread for each client that connects
-> create POP3 server thread
-> create thread for each client that connects
Stop Mailserver ->
-> Shutdown SMTP and POP3 thread and their children threads
Is this a good architecture to use in a server?
If yes, how do I gracefully shut down the threads? Right now I have a method "Stop" that will set a static volatile bool stop to true which will cause some while-loops to terminate, but that doesn't work, the loops don't register that "stop" has changed to true
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I can't advise you on the arhitecture, becouse I have never programed a server of any kind (but I supose I would go the same way as you went...).
Anyways for the killing threads part: create a collection of your threads objects (I'm a little bit rusty on this part, but I do know that every thread has an object) and then when you have to kill them, just loop trough that collection and shut the threads down...
Easy.
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|