delegate void SetControlValueCallback(Control oControl, string propName, object propValue);
private void SetControlPropertyValue(Control oControl, string propName, object propValue)
{
if (oControl.InvokeRequired)
{
SetControlValueCallback d = new SetControlValueCallback(SetControlPropertyValue);
oControl.Invoke(d, new object[] { oControl, propName, propValue });
}
else
{
Type t = oControl.GetType();
PropertyInfo[] props = t.GetProperties();
foreach (PropertyInfo p in props)
{
if (p.Name.ToUpper() == propName.ToUpper())
{
p.SetValue(oControl, propValue, null);
}
}
}
}
Thread thread = new Thread(new ThreadStart(Generate));
thread.Name = "Generate";
thread.IsBackground = true;
thread.Start();
The control properties like progressbar properties can be set in Generate Method
SetControlPropertyValue(progressBar1, "Visible", true);
SetControlPropertyValue(progressBar1, "Minimum", 0);
SetControlPropertyValue(progressBar1, "Maximum", dtCompareSets.Rows.Count);
Thursday, April 30, 2009
Tuesday, April 28, 2009
Authenticate the logged on windows user
string userId = Environment.UserName;
public class Authenticate
{
[DllImport("SenaInet.dll")]
static extern int getAuthToken (string tokentype, StringBuilder tokenbuf,ref long tokenbuflen, StringBuilder idbuf, ref long idbuflen);
public static string UserToken()
{
String tokenType = "ldap";
String userid;
String token;
int retcode = 0;
long tbuflen = 16000;
StringBuilder tbuf = new StringBuilder (Convert.ToInt32 (tbuflen));
long ibuflen = 16000;
StringBuilder ibuf = new StringBuilder (Convert.ToInt32 (ibuflen));
retcode = getAuthToken(tokenType,tbuf,ref tbuflen,ibuf,ref ibuflen);
token = tbuf.ToString();
return token;
}
}
public class Authenticate
{
[DllImport("SenaInet.dll")]
static extern int getAuthToken (string tokentype, StringBuilder tokenbuf,ref long tokenbuflen, StringBuilder idbuf, ref long idbuflen);
public static string UserToken()
{
String tokenType = "ldap";
String userid;
String token;
int retcode = 0;
long tbuflen = 16000;
StringBuilder tbuf = new StringBuilder (Convert.ToInt32 (tbuflen));
long ibuflen = 16000;
StringBuilder ibuf = new StringBuilder (Convert.ToInt32 (ibuflen));
retcode = getAuthToken(tokenType,tbuf,ref tbuflen,ibuf,ref ibuflen);
token = tbuf.ToString();
return token;
}
}
Subscribe to:
Posts (Atom)