What do you intend to do during the scan?
If you are looking for changes then you could use a FileSystemWatcher to do the "scanning" for you.

commented: actually i want to scan my files in a directory after every 10 min.... thay why my own file allocation update its information.... because when a file is moved from one folder to other or it delete then my file allocation table must be updated for every in +0

I suspect that Metadata is blocking waiting for your function to return before it can call it again.
It would be better to call the GUI method on a new thread as this allows you to exit the function early.
This will enable Metadata to call your function again while you update your GUI (you will need to keep track of each result set though).

How are you getting the path to your[I] applicationSettings.data[/I] file?
Is this a hard coded text path like this [iCODE]appdatapath = @".\Application Settings folder\applicationSettings.data";[/iCODE]?
Or perhaps you use [I]Environment.CurrentDirectory[/I] as the base path?

If so perhaps you should consider the following

@VIeditorlover: Not a bad solution but that alone will not fix the problem.

What I think is happening is :
[INDENT][I]NNExportDLL[/I] must wait for [I]ComputeNN[/I] to finish before it updates the GUI
This blocks the main thread from receiving the return value
which makes the GUI unresponsive.[/INDENT]

If the calling app is running this function on its UI thread then this will make things even more unresponsive.

I thought about your problem a bit more.
What do you think about the following.

Remove the [I]GUI [/I]call from [I]NNExportDLL [/I] function and make it an external function (or wrapper it in an [I]GUIUpdate [/I]function).
Then make the calling app call [I]NNExportDLL [/I]in background threads and call [I]GUIUpdate [/I]at a less frequent interval on its main thread.

Some indication of what you have tried would be helpful.

Is this a windows forms application or some other flavour of C#?

It seems the DLL is written by you. Is this correct?

What is calling the DLL and how?

Is ComputeNN dependant upon the results of PrepareData?

From your description of the problem and the pseudo-code you posted it is not clear what is causing the flicker.
Please give a more detailed snippet of your actual code.

This is probably due to reading and writing synchronously.
There something about this in the help for RedirectStandardOutput.

MSDN redirection online help:

Here is the same program again only using the [I]switch[/I] command mentioned by ddanbe.
This is very similar to using the [I]if - else if - else if [/I] of the previous program.
[CODE]static void Main(string[] args)
Console.Write("Enter a number: ");
int iNum = 0;
// read a value entered on the keyboard and converts it to a number
int.TryParse(Console.ReadLine().Trim(), out iNum);

switch (iNum)
    case 28:
        Console.WriteLine("Month is February");
    case 30:
        Console.WriteLine("Months are April ..."); // other month need to be added
    case 31:
        Console.WriteLine("Months are ..."); // add months
        Console.WriteLine("No months have that many days.");

Console.Write("Press any key to continue...");


You all have missed the key point in the original question.
The fact that the OP is a [B]beginner[/B]!
Here is a basic program that demonstrates the use of the [I]if else[/I] command.
[CODE]static void Main(string[] args)
Console.Write("Enter a number: ");
int iNum = 0;
// read a value entered on the keyboard and converts it to a number
int.TryParse(Console.ReadLine().Trim(), out iNum);

if (iNum == 28)
    Console.WriteLine("Month is February");
else if (iNum == 30)
    Console.WriteLine("Months are April ..."); // other month need to be added
else if (iNum == 31)
    Console.WriteLine("Months are ..."); // add months
    Console.WriteLine("No months have that many days.");
Console.Write("Press any key to continue...");


You can use the CellFormatting event to do this.
The following code snippet colours cells in the third column if they have a value of "-1".
[CODE] private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
var cell = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex];
if (e.ColumnIndex == 2 && ((string)cell.Value) == "-1")
e.CellStyle.ForeColor = Color.Red;
You must check the column index to ensure the test is applied to the right data value.

Posted in error.

Line 57 is where the problem is.
Here you are directly referencing only the first PictureBox with index of j=0.
You need to convert [I]sender[/I] in to a picture box and use that instead.
Try this.
[CODE] if (System.IO.File.Exists(imgshow) && sender is PictureBox)
((PictureBox)sender).ImageLocation = imgshow;
This adds a test to confirm that the sender is a PictureBox to prevent invalid cast errors.
Then cast sender to a PictureBox to set the new picture location.

Try changing the listbox item value instead of using Add and RemoveAt.
e.g. [iCODE]listbox1.Items[sl-1] = percent.ToString();[/iCODE]

Your welcome.
If your question is answered then please mark the thread as solved so others know you no longer need help. Thanks.

If you intend to use the same [I]ContextMenu [/I]for each picture box then delcare the menu variable at form level instead of inside the button click handler.

To add a picture box at run time you create a new PictureBox object and add it to the form's (or other container's) [I]Controls [/I]collection after setting the [I]Size[/I],[I]Location [/I]and other properties.

To get an idea of how this is done, add a [I]PictureBox [/I]to your form, set some of the properties and save the form. Then look in the <formname>.designer.cs file for how the Form Designer codes this for you.

If you get stuck, just post your efforts and someone will help you.

You are not adding an event handler for the click event of the menu items.
You need to do something like this.
[CODE] private void button1_Click(object sender, EventArgs e)
int iCtr = 0;
ContextMenuStrip docmenu = new System.Windows.Forms.ContextMenuStrip();
DialogResult result = folderBrowserDialog1.ShowDialog();
if (result == DialogResult.OK)
string[] files = Directory.GetFiles(folderBrowserDialog1.SelectedPath);
//MessageBox.Show("Files found: " + files.Length.ToString(), "Message");
foreach (string imageFile in files)
ToolStripMenuItem openimg = new ToolStripMenuItem();
openimg.Text = imageFile;[COLOR="red"] //<-- imageFile is already a string![/COLOR]
openimg.Click += menuitem_Click; [COLOR="Green"]//<-- attach to click event handler[/COLOR]
iCtr++;[COLOR="red"] //<---????[/COLOR]
docmenu.Items.Add(openimg); [COLOR="Red"]//<-- use Add to add a single item[/COLOR]
pictureBox8.ContextMenuStrip = docmenu;

    // handle image context menu item click events
    private void menuitem_Click(object sender, EventArgs e)
        ToolStripMenuItem item = sender as ToolStripMenuItem;
        // edit if not a toolstrip menu
        if (item == null)
        // do something with item
        // e.g. Open file based on filename in Text property
        MessageBox.Show(string.Format("Selected Image File = \"{0}\"", item.Text), "Item Selected");

The objects in System.Xml.Link namespace are a little easier to user than the System.Xml namespace objects.
You will need to add a reference to System.Xml.Link in you project reference.

[CODE] private void load_xml2(string xml)
var xDoc = XDocument.Load(Application.StartupPath + "\RSS\" + xml + ".xml");

        // find channel element to append to (exit if not found)
        var channel = xDoc.Descendants("channel").ElementAt(0);
        if (channel == null)
        // create new item with sub tags
        var newItem = new XElement("item", 
            new XElement("title","New Item Title"),
            new XElement("description", "NEW ITEM"),
            new XElement("link", "Link to item"));
        // add new item to first channel

        xDoc.Save(Application.StartupPath + "\\RSS\\" + xml + "2.xml");


You are appending to the root node of the document (in this case the [I]rss [/I]element).
You need to append to the [I]channel [/I]element; which you must find first.
Check my earlier post to see one way to do this.

Even though you have created a new element on the document you need to add it to a node for it to be added to the document.

The following snippet should get you started.
[CODE] private void load_xml(string xml)
XmlDocument xDoc = new XmlDocument();
xDoc.Load(Application.StartupPath + "\RSS\" + xml + ".xml");

        // [COLOR="Green"]find channel element to append to[/COLOR]
        var channels = xDoc.GetElementsByTagName("channel", string.Empty);
        // if no channel tags then exit
        if (channels.Count==0)
        // create new item
        var newItem = xDoc.CreateElement("item");
        // [COLOR="Green"]add attributes (with value) [/COLOR]
        // [COLOR="Red"]Note: You do not have any attributes in your xml.[/COLOR]
        // [COLOR="Red"]This is added to show you how to do it and what the effect is.[/COLOR]
        newItem.SetAttribute("name", "NewItem");
        // [COLOR="green"]create and add item sub tags[/COLOR]
        var description = xDoc.CreateElement("description");
        description.InnerText = "NEW ITEM";
        // [COLOR="green"]add new item to first channel[/COLOR]

        xDoc.Save(Application.StartupPath + "\\RSS\\" + xml + ".xml");


To use the [I]DataSource [/I]property of the data grid you must also bind any DataGridColumns you create to the columns of the data table. To do this you set the [I]DataPropertyName[/I] property to the name of the bound column in the data table.
If you do not do this then the data grid creates new columns for each column in the data table. (Perhaps this is why you cannot change the colours of the cells when using DataSource.)

Setting cell colours when using a DataSource is best done in the DataGrid.CellFormatting event as the data grid uses this to determine how to display the cell.
The snippet below changes the background for modified cells.
[CODE] private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
// get bound row for cell being formatted.
var drv = dataGridView1.Rows[e.RowIndex].DataBoundItem as DataRowView;

        // if row not bound then ignore it
        if (drv == null || drv.Row == null)

        // get local reference to row
        var row = drv.Row;

        // if row has original and current (new) value then test further
        if (row.HasVersion(DataRowVersion.Current) && row.HasVersion(DataRowVersion.Original))
            // get original and current values
            object original = row[e.ColumnIndex, DataRowVersion.Original];
            object current = row[e.ColumnIndex, DataRowVersion.Current];
            // if original not same as current then change background colour of cell
            if (!current.Equals(original))
                e.CellStyle.BackColor = Color.PowderBlue;


If you are still having trouble with this then you need to find out where the error is coming from.

If the debugger is not breaking in your code then you might benefit from trapping the first time exceptions. To do this use menu [I]Debug/Exceptions...[/I] then check [I]Common Language Runtime Exception[/I] to break when first thrown. Now when you debug your program it should break immediately the error occurs at the point in your code where it happens.

You should now try to fix the problem by understanding what causes it, then prevent it from happening.

For those occations when it is not possible to fix the problem then it is possible to trap the error using the [URL="

Please do not post the same question twice.
Refer to your [URL="

Have you seen [URL="

[QUOTE=karlitros2130;1657451]try this

B162_Calc = Financial.IRR(ref testvalues, 1);[/QUOTE]
Thanks for the input but this thread is over a year old.
I think by now the original problem has probably been solved.

[QUOTE=x38class;1657465]Firstly, please use [CODE][/CODE] tags around your code.[/QUOTE]
In the forums here at Daniweb it is required that you put code tags around your code so that it is formatted as code.
(On your post you'll see that the administrator has kindly added the tags for you.)

It is not clear from the code you have posted where the problem might be.
Please post your code that handles the change in the drive selection on the list box.
Also, please post your original code again, but this time post the whole subroutine(s).

Firstly, please use [noparse][CODE][/CODE][/noparse] tags around your code.

You could use the [URL="

This might help

Click on your <DBname>.mdf (...\DB\emp.mdf) file in your project.
Look in the Properties view.
What is the value for the property "[I]Copy to Output Directory[/I]"?

If it is set to "Copy always" then every time you build your project the DB file in the Debug folder is overwritten!
This is probably why your data is apparently not saved between runs.

Did you read my post?
What is [I]Copy to Output Directory[/I] set to for your .dbf file?