|
I would read the first as there is/was "something", but it is not valid.
The second is more like, there is "nothing" or "not applicable", not applicable is even more correct I think.V.
|
|
|
|
|
Hi all, i read that but don't understand it, can you illustrate it to me, pleae,,.
<pre>[SuppressUnmanagedCodeSecurityAttribute]</pre>
// Allows managed code to call into unmanaged code without a stack walk.
// 1- This attribute can be applied to methods that want to call into native
// code without incurring the performance loss of a run-time security check when doing so.
// 2- Using this attribute in a class applies it to all contained methods.
regards..,
|
|
|
|
|
This just basically means what it says:
Increase performance when using pInvoke, but make sure to deal with the security issues that follows.
Every method in a class decorated with this attribute also gets the attribute.
|
|
|
|
|
helo,
i want to create a process,that if i click log-off to my user is still running and working.
how i do it?services?system process?Special process?
I would be happy to detail some.
Me.
|
|
|
|
|
Windows Service would be the way to go, set to 'automatic' to get it to start when the computer does, and probably using the local system account. Regards,
Rob Philpott.
|
|
|
|
|
Yes, a Windows (NT) Service is the way to go here. There are plenty of articles on how to create one so google will provide you with many of relevant answers on this matter. Good luck!
|
|
|
|
|
A Windows Scheduled Task might do it as well.
|
|
|
|
|
Hi,
I would like to use Multi threading to improve the performance. I have a datatable it may have any no of records. But the problems is i have to split those records and assign some records to one thread, some other records to other thread and so on.
I will pass the table,no of threads, records for thread like the following
public void MultiThreadingSample(DataTable table, int noOfThreads,int recordsForThread)
{
}
please help to me.
|
|
|
|
|
Hi Guys. I have a slight problem. I have written an app that processes various types of files. I create a Thread for each type of file being processed depending on a checkbox being checked.
Now, from each file processed I output totals to a label on the form. However, this only seems to work for the first two files being processed and the remainder does not get their totals output to the labels. Is this a known issue and is there a way I can get around this? The code is kinda long so don't really want to add any here now. But the process flow of the program is such.
1) User selects a searches for file to process.
2) User checks the appropriate checkbox.
3) Thread is started calling the block of code to run.
4) Once file is processed finalize by calling GC.Collect().
if user wants to process another file he unchecks the current chechbox, checks a new checkbox and searches for new file and above process is followed calling the appropriate Thread to run.
Can somebody advise why when running more than two "Thread" processes in succession results in the third and fourth not outputting totals to the Label's?Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Without some idea of the code it is really difficult to suggest anything, but there general things you can check:
Are the thread running at all? Add some logging to a file to record what is being done, and in what order.
Are the output overwriting each other? Try logging the outputs as well.
Are the thread having problems with conflicts? Are there any locks which might be waiting?
Is it always the same threads that don't run? Or does that change depending on what order they are started in, say?
Sorry not to give concrete answers, but there is a heck of a lot that could be going wrong here - I think your first call is to gather more info!If Barbie is so popular, why do you have to buy her friends?
Eagles may soar, but weasels don't get sucked into jet engines.
If at first you don't succeed, destroy all evidence that you tried.
|
|
|
|
|
Hi Griff. The Threads are all running. Output is created from all the Threads. However, I display some totals on screen for the user to verify against. It will output the totals for two of the threads run after each other, but when running the third and fourth thread I get no totals output to screen. I have tested by adding the totals to a messagebox after it is supposed to be output to the label and that works.
Below is the code. It might be long but this is what I have.
#region Set Text Code
public delegate void SetText(Control ctrl, string str);
public delegate void SetLabel(Control lblctrl, string filename);
private delegate void updateBar();
private void setText(Control ctrl, string str)
{
if (this.WindowState == FormWindowState.Minimized)
return;
if (ctrl.InvokeRequired)
ctrl.BeginInvoke(new SetText(setText), new object[] { ctrl, str });
else
ctrl.Text = str;
}
private void setFilename(Control lblctrl, string filename)
{
if (this.WindowState == FormWindowState.Minimized)
return;
if (lblctrl.InvokeRequired)
lblctrl.BeginInvoke(new SetLabel(setFilename), new object[] { lblctrl, filename });
else
lblctrl.Text = filename;
}
private void finalizeProcess()
{
GC.Collect();
}
#endregion
#region Open File Dialog Code
private void button3_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() != DialogResult.OK)
{
return;
}
else
{
txtboxSelectFile.Text = openFileDialog1.FileName;
}
}
#endregion
#region Select File Code
private void btnStart_Click(object sender, EventArgs e)
{
setText(this, "Checking Process Selection");
if (chkboxHolders.CheckState == CheckState.Unchecked && chkboxCert.CheckState == CheckState.Unchecked &&
chkboxPiadd.CheckState == CheckState.Unchecked && chkboxDivRecords.CheckState == CheckState.Unchecked)
{
MessageBox.Show("Please make a valid processing selection", "Invalid Process Selection",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
if (chkboxHolders.Checked)
{
setText(this, "Holder File Processing Selected");
processHolders();
}
if (chkboxCert.Checked)
{
setText(this, "Certificate File Processing Selected");
processCerts();
}
if (chkboxPiadd.Checked)
{
setText(this, "Payment Instruction File Processing Selected");
processDiv();
}
if (chkboxDivRecords.Checked)
{
setText(this, "Create Dividend Files");
processDividends();
}
}
}
#endregion
#region All Threading Code
private void processHolders()
{
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
ThreadStart starthld = new ThreadStart(convertHolders);
Thread threadhld = new Thread(starthld);
threadhld.Start();
}
}
private void processCerts()
{
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
ThreadStart startcert = new ThreadStart(convertCert);
Thread threadcert = new Thread(startcert);
threadcert.Start();
}
}
private void processDiv()
{
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
ThreadStart startdiv = new ThreadStart(convertDiv);
Thread threaddiv = new Thread(startdiv);
threaddiv.Start();
}
}
private void processDividends()
{
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
ThreadStart startdivs = new ThreadStart(convertDividendPayments);
Thread threaddivs = new Thread(startdivs);
threaddivs.Start();
}
}
#endregion
#region All Processing Code
private void convertHolders()
{
string infile;
infile = txtboxSelectFile.Text;
string outfile;
outfile = saveFileDialog1.FileName;
string holdline;
StreamReader sr = new StreamReader(infile);
StreamWriter sw = new StreamWriter(outfile);
setText(this, "Start Holder File Conversion");
int holdercount = 0;
Int64 currentbal = 0;
Int64 oldbal = 0;
long ShareTotal = 0;
long ShareOld = 0;
while (!sr.EndOfStream)
{
holdline = sr.ReadLine();
string HID = holdline.Substring(0, 10);
string Title = holdline.Substring(10, 45).Trim();
string Surname = holdline.Substring(55, 100).Trim();
string FirstName = holdline.Substring(155, 100).Trim();
string OtherNames = holdline.Substring(255, 100).TrimEnd();
string Gender = holdline.Substring(355, 1);
string Addr1 = holdline.Substring(356, 35).TrimEnd();
string Addr2 = holdline.Substring(396, 35).TrimEnd();
string Addr3 = holdline.Substring(436, 35).TrimEnd();
string Addr4 = holdline.Substring(476, 35).TrimEnd();
string Addr5 = holdline.Substring(516, 35).TrimEnd();
string PostCode = holdline.Substring(556, 10).TrimEnd();
string Nationality = holdline.Substring(566, 25).TrimEnd();
string BranchCode = holdline.Substring(591, 6);
string AccountNumber = holdline.Substring(597, 16);
string AccountType = holdline.Substring(613, 2);
string NationalId = holdline.Substring(615, 16).TrimEnd();
string TotalShares = holdline.Substring(631, 18);
string FullName = Title + " " + FirstName + " " + Surname;
int namelen = FullName.Length;
int namerem = namelen - 35;
currentbal = Convert.ToInt64(TotalShares);
string OldBalance = holdline.Substring(649, 18);
oldbal = Convert.ToInt64(OldBalance);
setText(this, "Processing HolderID: " + HID);
if(namelen > 35)
{
sw.Write(" ".PadRight(5, ' ') + "NAADD" + " ".PadRight(7, ' ') + "C" + HID +
FullName.Substring(0, 35).PadRight(35, ' ') + FullName.Substring(35, namerem).PadRight(35, ' ') +
Addr1.PadRight(35, ' ') + Addr2.PadRight(35, ' ') + Addr3.PadRight(35, ' ') + Addr4.PadRight(35, ' ') +
Addr5.PadRight(35, ' ') + " ".PadRight(35, ' ') + PostCode.PadRight(5, ' ') + "ZAF" +
"IND" + " ".PadRight(57, ' ') + HID.PadRight(12, ' ') + " ".PadRight(13, ' '));
}
else if (namelen <= 35)
{
sw.Write(" ".PadRight(5, ' ') + "NAADD" + " ".PadRight(7, ' ') + "C" + HID + FullName.Trim().PadRight(35, ' ') +
Addr1.PadRight(35, ' ') + Addr2.PadRight(35, ' ') + Addr3.PadRight(35, ' ') + Addr4.PadRight(35, ' ') +
Addr5.PadRight(35, ' ') + " ".PadRight(70, ' ') + PostCode.PadRight(5, ' ') + "ZAF" +
"IND" + " ".PadRight(57, ' ') + HID.PadRight(12, ' ') + " ".PadRight(13, ' '));
}
if (NationalId == "" || NationalId.Length < 13)
{
sw.Write(" ".PadRight(1142, ' ') + " ".PadRight(1456, ' ') + Environment.NewLine);
}
else
{
sw.Write("Z" + NationalId.PadRight(16, ' ') + " ".PadRight(1125, ' ') + " ".PadRight(1456, ' ') + Environment.NewLine);
}
ShareTotal = ShareTotal + currentbal;
ShareOld = ShareOld + oldbal;
holdercount++;
}
sr.Close();
sw.Close();
setFilename(lblShareTotals, ShareTotal.ToString());
setFilename(lblHolderTotal, holdercount.ToString());
setFilename(lblOldBalanceTotals, ShareOld.ToString());
this.progressBar1.Invoke(new updateBar(this.finalizeProcess));
MessageBox.Show("Completed Processing Holder File", "Holder File Completed",
MessageBoxButtons.OK, MessageBoxIcon.Information);
setText(this, "Holder File Processing Completed");
}
private void convertCert()
{
string infile;
infile = txtboxSelectFile.Text;
string outfile;
outfile = saveFileDialog1.FileName;
string holdline;
Int64 currentbal = 0;
long ShareTotal = 0;
int totaltrans = 0;
StreamReader sr = new StreamReader(infile);
StreamWriter sw = new StreamWriter(outfile);
setText(this, "Start Certificate File Conversion");
while (!sr.EndOfStream)
{
holdline = sr.ReadLine();
string HID = holdline.Substring(0, 10);
string day = holdline.Substring(10, 2);
string month = holdline.Substring(13, 2);
string year = holdline.Substring(16, 4);
string cert = holdline.Substring(20, 10).Trim();
string transaction = holdline.Substring(30, 55).TrimEnd();
string shares = holdline.Substring(85, 18);
setText(this, "Processing HolderID: " + HID);
if (chkoxCreateCerts.Checked)
{
if (shares != "000000000000000000")
{
sw.WriteLine(" ".PadRight(5, ' ') + "CAPIN" + " ".PadRight(8, ' ') +
day + month + year.Substring(2, 2) + "+" + shares.Substring(4, 14) + "000000" +
"ORD" + "ZAF" + " ".PadRight(5, ' ') + "C" + HID + " ".PadRight(10, ' ') +
cert.PadLeft(12, '0') + " ".PadRight(2911, ' '));
currentbal = Convert.ToInt64(shares);
ShareTotal = ShareTotal + currentbal;
}
}
else
{
if (shares != "000000000000000000")
{
sw.WriteLine(" ".PadRight(5, ' ') + "ADJIN" + " ".PadRight(8, ' ') +
day + month + year.Substring(2, 2) + "+" + shares.Substring(4, 14) + "000000" +
"ORD" + "ZAF" + " ".PadRight(5, ' ') + "C" + HID + " ".PadRight(10, ' ') +
cert.PadLeft(12, '0') + " ".PadRight(2911, ' '));
currentbal = Convert.ToInt64(shares);
ShareTotal = ShareTotal + currentbal;
}
}
totaltrans++;
}
setFilename(lblCertificateTotals, totaltrans.ToString());
setFilename(lblCertificateBalance, ShareTotal.ToString());
sr.Close();
sw.Close();
this.progressBar1.Invoke(new updateBar(this.finalizeProcess));
MessageBox.Show("Completed Processing Certificate File", "Certificate File Completed",
MessageBoxButtons.OK, MessageBoxIcon.Information);
setText(this, "Certificate File Processing Completed");
}
private void convertDiv()
{
string infile;
infile = txtboxSelectFile.Text;
string outfile;
outfile = saveFileDialog1.FileName;
string holdline;
int totalCount = 0;
StreamReader sr = new StreamReader(infile);
StreamWriter swb = new StreamWriter(outfile);
setText(this, "Start Payment Instruction Conversion");
while (!sr.EndOfStream)
{
holdline = sr.ReadLine();
string HID = holdline.Substring(0, 10);
string BranchCode = holdline.Substring(591, 6);
string AccountNumber = holdline.Substring(597, 16);
string shares = holdline.Substring(85, 18);
string newBranch = BranchCode.Substring(0, 3) + "-" + BranchCode.Substring(3, 3);
setText(this, "Processing HolderID: " + HID);
if (BranchCode != " ")
{
if (shares != "000000000000000000")
{
swb.WriteLine(" ".PadRight(5, ' ') + "PIADD" + " ".PadRight(7, ' ') + "C" + HID + "10" +
"D" + " " + newBranch.PadRight(10, ' ') + AccountNumber.PadRight(16, ' ') + " ".PadRight(2940, ' '));
totalCount++;
}
}
}
sr.Close();
swb.Close();
setFilename(lblPaymentInstrucTotals, totalCount.ToString());
this.progressBar1.Invoke(new updateBar(this.finalizeProcess));
MessageBox.Show("Completed PIADD Conversion", "PIADD Conversion Message",
MessageBoxButtons.OK, MessageBoxIcon.Information);
setText(this, "Payment Instruction File Processing Completed");
}
private void convertDividendPayments()
{
string filePath;
string inFile;
string holdLine;
inFile = txtboxSelectFile.Text;
filePath = folderBrowserDialog1.SelectedPath;
long TotalGross = 0;
long TotalTax = 0;
long TotalNet = 0;
Int64 gross = 0;
Int64 tax = 0;
Int64 net = 0;
StreamReader sr = new StreamReader(inFile);
StreamWriter swp = new StreamWriter(Path.Combine(filePath, "er_au_xxxx_seqmpd.temp"));
setText(this, "Starting Payment File Conversions");
while (!sr.EndOfStream)
{
holdLine = sr.ReadLine();
string DividendNumber = holdLine.Substring(0, 9).TrimEnd();
string CADescription = holdLine.Substring(9, 55);
string HolderRef = holdLine.Substring(64, 10);
string PaymentType = holdLine.Substring(74, 1);
string PaymentRef = holdLine.Substring(75, 10);
string LdrBal = holdLine.Substring(85, 18);
string GrossAmount = holdLine.Substring(103, 18);
string TaxAmount = holdLine.Substring(121, 18);
string NetAmount = holdLine.Substring(139, 18);
string PaymentStatus = holdLine.Substring(157, 1);
string PaymentDate = holdLine.Substring(158, 10);
gross = Convert.ToInt64(GrossAmount);
tax = Convert.ToInt64(TaxAmount);
net = Convert.ToInt64(NetAmount);
setText(this, "Processing HolderID: " + HolderRef);
swp.Write("C" + HolderRef + "DIV" + DividendNumber + PaymentRef.Substring(2, 8).PadLeft(8, '0'));
if (PaymentType == "E")
{
swp.Write("D" + PaymentDate.Substring(0, 2) + PaymentDate.Substring(3, 2) + PaymentDate.Substring(6, 4));
}
else
{
swp.Write(PaymentType + " ".PadRight(8, ' '));
}
swp.Write(GrossAmount.Substring(7, 11) + "00" + TaxAmount.Substring(7, 11) + "00" + NetAmount.Substring(7, 11) + "00" + "S");
if (PaymentStatus == "P")
{
swp.Write("2");
}
if (PaymentStatus == "C")
{
swp.Write("3");
}
if (PaymentStatus == "U")
{
swp.Write("1");
}
if (PaymentStatus == "R")
{
swp.Write("E");
}
swp.Write("R" + " ".PadRight(24, ' ') + Environment.NewLine);
TotalGross = TotalGross + gross;
TotalTax = TotalTax + tax;
TotalNet = TotalNet + net;
}
sr.Close();
swp.Close();
setFilename(lblGrossTotals, TotalGross.ToString());
setFilename(lblTaxTotals, TotalTax.ToString());
setFilename(lblNetTotals, TotalNet.ToString());
this.progressBar1.Invoke(new updateBar(this.finalizeProcess));
MessageBox.Show("Completed Dividend Payment Processing", "Dividend Processing",
MessageBoxButtons.OK, MessageBoxIcon.Information);
setText(this, "Dividend File Processing Completed");
}
#endregion
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Without actually running it, I can't see anything obviously wrong.
Since this is the code that (doesn't) show the problem, I would be tempted to try
private void setFilename(Control lblctrl, string filename)
{
Console.WriteLine("setFileName Entered: " + lblCtrl.Name + " : " + filename);
if (this.WindowState == FormWindowState.Minimized)
return;
Console.WriteLine("setFileName PreInvokeCheck: " + lblCtrl.Name + " : " + filename);
if (lblctrl.InvokeRequired)
{
Console.WriteLine("setFileName BeginInvoke: " + lblCtrl.Name + " : " + filename);
lblctrl.BeginInvoke(new SetLabel(setFilename), new object[] { lblctrl, filename });
}
else
{
Console.WriteLine("setFileName Direct: " + lblCtrl.Name + " : " + filename);
lblctrl.Text = filename;
}
}
Or equivilent to check if it gets to the "setFileName Direct" bit when you don't get the label written. It may give a clue to what is going on (or worse, remove the problem)If Barbie is so popular, why do you have to buy her friends?
Eagles may soar, but weasels don't get sucked into jet engines.
If at first you don't succeed, destroy all evidence that you tried.
|
|
|
|
|
Thanks mate. I will give it a go and post back. It is just strange that it does it for two consecutive runs but for the third and fourth it doesn't. And it doesn't matter in what order it is run or not. Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Hi,
you are not supposed to touch a Control from a thread that did not create the Control. While your code is using several InvokeRequired/Invoke patterns, it is also not using them in several locations, see:
1.
if (this.WindowState == FormWindowState.Minimized)
is probably OK, but not documented to be OK
2.
infile = txtboxSelectFile.Text;
is probably not OK (not documented, I guess it is not OK for Controls that allow text editing)
3.
outfile = saveFileDialog1.FileName;
is most likely not OK, file dialogs are known to be critical (e.g. you need STAThread for them)
IMO you should fix all of the above.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
Hi Guys,
I'm trying to do something that looks easy but for some reason doesn't work.
I have a window service which loads .dll's that are in a different directory every couple of minutes.
I need to update those .dll's every now an than so I created an AppDomin and from there I want to load the .dll's in to the main AppDomain.
The strange thing is when I try to load a .dll I get an exception that the .dll can't be found.
Here's the source code:
AppDomainSetup AppDomSetup = new AppDomainSetup();
AppDomSetup.ApplicationName = "Service Name";
AppDomSetup.ApplicationBase = Application.StartupPath;
AppDomSetup.PrivateBinPath = "alerts";
AppDomSetup.ShadowCopyFiles = "true";
AppDomSetup.CachePath = Path.Combine(Application.StartupPath, "_cache");
m_FilesDomain = AppDomain.CreateDomain("Ksm Scheduler", null , AppDomSetup);
m_FilesDomain.Load("alert1.dll");
The 'PrivateBinPath' property points to the directory that contains the .dll's.
The 'cache path' folder IS CREATED but I get an exception. When I place the .dll's in the 'ApplicationBase' directory i.e. in the directory of the .exe file, the .dll is loaded.
Thanks for any help,
Avi
|
|
|
|
|
Don't have an answer to your immediate questions, but a couple of queries. Firstly, are all these DLLs .NET assemblies? Are you using shadowing so you don't lock the file in question so it can be altered elsewhere? When a dll is changed, do you want to unload the last one and replace it with the new one?
The bit which sounds really odd is loading the dll into the main application domain (which you can't unload). Do you not want to create a new domain, load the dlls in there and then unload it when they need to be updated?Regards,
Rob Philpott.
|
|
|
|
|
Hi Rob,
1. Rob Philpott wrote: are all these DLLs .NET assemblies?
Yes, all the DLL's .NET assemblies.
2. Rob Philpott wrote: Are you using shadowing so you don't lock the file in question so it can be altered elsewhere?
Yes I'm.
3. Rob Philpott wrote: When a dll is changed, do you want to unload the last one and replace it with the new one?
Yes, exactly.
Rob Philpott wrote: Do you not want to create a new domain, load the dlls in there and then unload it when they need to be updated?
I DO want to create a NEW domain, which I did, but for some reason the .dll aren't loaded into it. Besides, Although I don't understand how the .dll file, after is was updated, gets updated also in the new doamin without me unloading it i.e. I don't want to unload the .dll when it's changed. That is the whole purpose of shdowing, right? ( or wrong?)
One more important thing.
If I place the .dll's inside the ApplicationBase directory, the .dll's ARE loaded. When I create the new domain I give it a AppDomainSetup object with all the details. I assign to the PrivateBinPath the folder which the .dll's reside ( the folder is inside the main application folder, of course)
|
|
|
|
|
Hi
Is there any open source library C#/C++/C which will give me the delta changes of file (it can be any type)?
Thanks ...
|
|
|
|
|
Hello All,
I have an issues, i want to cancel the dropdown from being opened after validating the dropdown button clicked.
i tried with setting droppeddown property to true as suggested by one of the member from this forum in earlier post. But that is also not avoiding the dropdown from being opened.
I also tried to override the wndProc method and canceling the event it self but that is also not working . Please suggest me what i need to do so that i can avoid the dropdown after custom validation.
Thanks in Advance.
Ron
|
|
|
|
|
Hello, I think this can be done by intercepting WM_COMMAND message in "WndProc" method.
this may help
public class SuperComboBox:ComboBox
{
public class DropDownValidate:EventArgs
{
public bool AllowDropDown{get;set;}
public DropDownValidate()
{
this.AllowDropDown = true;
}
}
private const int WM_COMMAND = 0x0111;
public event EventHandler<DropDownValidate> ValidateOnDropDown;
private bool _haltDrop;
protected virtual void OnValidateDropDown(DropDownValidate e)
{
if (this.ValidateOnDropDown != null)
this.ValidateOnDropDown(this, e);
}
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_COMMAND)
{
var validationArg = new DropDownValidate();
this.OnValidateDropDown(validationArg);
_haltDrop = !validationArg.AllowDropDown;
if (_haltDrop) return;
}
base.WndProc(ref m);
}
}
Good luck
|
|
|
|
|
I have a project with many object within objects and it take a while for it to refresh when the data is changed or the form is resized. I think I have too many daisy chained events occuring.
I notice that when the Visual C# produces code it will put the "new" declarations before the SuspendLayout statement.
Object = new MediaIcon;
this.SuspendLayout();
Object.Left = 10;
.....
this.Controls.Add(Object);
this.ResumeLayout(false);
this.PerformLayout();
this is simple for a one of object, but when you have an array of them can you put the new commands within the bounds of the Suspend/Resume??
this.SuspendLayout();
Object = new MediaIcon[25];
for (int n = 0; n < 25; n++)
{
Object[n] = new MediaIcon();
Object[n].Tag = n;
.....
Object[n].Enter += new System.EventHandler(ClickButton);
this.Controls.Add(Object[n]);
}
FunctionIndex = MainForm.FunctionIndex;
this.Resize += new System.EventHandler(this.MediaBrowserClass_Resize);
this.Enter += new System.EventHandler(this.MediaBrowserClass_Enter);
this.ResumeLayout(false);
this.PerformLayout();
Could the way I am using the Suspend/Resume be the root cause of my slow refreshing?
Thank you in advance
|
|
|
|
|
Douglas Kirk wrote: I notice that when the Visual C# produces code it will put the "new" declarations before the SuspendLayout statement.
So what? The new control hasn't been added to the form's Controls collection yet, so it's not going to affect the layout of the form. it's perfectly logical to place the new outside of the suspend/resume layout block.
Douglas Kirk wrote: this is simple for a one of object, but when you have an array of them can you put the new commands within the bounds of the Suspend/Resume??
You can, but it doesn't change anything at all.
Douglas Kirk wrote: Could the way I am using the Suspend/Resume be the root cause of my slow refreshing?
No. Creating controls is a very expensive operation. If you're doing this on every refresh of the form, your creating a ton of controls every time something is dragged over your form.
|
|
|
|
|
Hi,
1.
please always show code inside PRE tags (e.g. use the "code block" widget), that makes it much more readable.
I may have overlooked something as it is now.
2.
Douglas Kirk wrote: can you put the new commands within the bounds of the Suspend/Resume??
yes. And IMO it won't make a difference.
3.
Douglas Kirk wrote: this.Controls.Add(Object[n]);
When you need to add a number of Controls, it is sometimes faster to use Controls.AddRange(), which Visual Designer also does.
4.
Not sure how long your constructors take, e.g. new MediaIcon(); that would depend on your code (not shown).
5.
Douglas Kirk wrote: it take a while for it to refresh when ... the form is resized.
That is not related to the code shown; it tells me your form probably is too complex. How many Controls are there? Do they overlap? Are there any background images? playing with transparency?
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
modified on Friday, February 12, 2010 4:44 AM
|
|
|
|
|
Hi friends
How to read news from a rss feed in c#
thanks in advance-kk.tvm-
|
|
|
|
|
|