|
Im not sure if this is the right place for this post, if not I apologize in advance this is my first time on the forum.
My question is - I am trying to write an Image Viewer program that reads the file paths from the file system and stores them in a list. Then it loads the first 25 images into an Image list(the 25 can be set to whatever I want.). That all works fine. The problem is when you get to the end of the 25 and its time to add more images. It works but is EXTREMELY slow. I cant seem to figure this out and have been playing with it for a while now. Any insight would be appriciated. Heres my code for adding to the buffer -
public void vScrollBar1_Scroll(object sender, ScrollEventArgs e) {
Thread addThread;
if(CurrentIndex <= BufferPadding / 2 + 1) {
CurrentIndex = vScrollBar1.Value;
PictureBox.Image = BufferedImageList[CurrentIndex];
} else {
if(CurrentIndex >= BufferPadding / 2 + 1 && CurrentIndex < ImagePathList.Count - 1) {
CurrentIndex = vScrollBar1.Value;
PictureBox.Image = BufferedImageList[BufferPadding / 2 + 1];
addThread = new Thread(new ThreadStart(AddToBuffer));
addThread.Start();
}
}
}
public void AddToBuffer() {
BufferedImageList.Add(DICOMImage.FromPath(ImagePathList[CurrentIndex]));
BufferedImageList[0].Dispose();
BufferedImageList.RemoveAt(0);
}
Thanks in advance
Brad
|
|
|
|
|
Hi there,
I have been trying to start some processes from my Windows service which is a multithreaded application and uses threadpool. I am able to start upto 24 processes (using ProcessInfo) but when the service try to start 25th an Application execption is logged in the eventlog:
Event Type: Error
Event Source: .NET Runtime
Event Category: None
Event ID: 0
Date: 9/8/2006
Time: 11:05:38 AM
User: N/A
Description:
The description for Event ID ( 0 ) in Source ( .NET Runtime ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. The following information is part of the event: .NET Runtime version 1.1.4322.573- .NET Framework Initialization Error: C:\WINNT\Microsoft.NET\Framework\v1.1.4322\mscorwks.dll could not be loaded.
I have tried setting maximum num of threads and IOCompletion threads using SetMaxThreads method exposed by ICorThreadPool interface, but no help.
Task manager shows threads count 20 and IO Write- 5 for the windows service.
Could it be appdomain or threadpool? Any helping comment much appreaciated.
Thanks,
|
|
|
|
|
Is it possible to create a system.data.datatable or dataset from an excel worksheet that is obtained using interop.excel in C#?
The code is as following. As you can see, I can read/modify certain cell, but is it possible to convert the table to a System.data.datatable? Or at least print out the select range in the excelworksheet?
protected void OpenExcelSpreadSheet(string input)
{
Excel.Application excelApp = new Excel.ApplicationClass();
excelApp.Visible = false;
Excel.Workbook newWorkbook =
excelApp.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
// The following code opens an existing workbook
object Missing = System.Reflection.Missing.Value;
string workbookPath= "myFile.xls";
Excel.Workbook excelWorkbook =
excelApp.Workbooks.Open(workbookPath,Missing,Missing,Missing,
Missing,Missing,Missing,Missing,Missing,Missing,Missing,Missing,Missing,Missing,Missing);
// The following gets the Worksheets collection
Excel.Sheets excelSheets = excelWorkbook.Worksheets;
// The following gets Sheet1 for editing
string currentSheet = "Sheet1";
Excel.Worksheet excelWorksheet = (Excel.Worksheet)excelSheets.get_Item(currentSheet);
// The following gets cell A1 for editing
Excel.Range excelCell = (Excel.Range)excelWorksheet.get_Range("A1", "A1");
excelCell.Value2 = input;
Excel.Range excelTable = (Excel.Range)excelWorksheet.get_Range("A1", "A27");
int noOfRow = excelTable.Rows.Count;
int noOfColumn = excelTable.Columns.Count;
Response.Write("Table has " + noOfRow + " rows and " + noOfColumn + " columns.
");
}
|
|
|
|
|
I want the functionality of converting digits into text. Any one give me code example or an article about that.
Example:
209
Two Hundred and Nine
thanks
"and Nader where are u i need u'r help"
-- modified at 14:42 Friday 8th September, 2006
Syed Shahid Hussain
|
|
|
|
|
Search this messageboard for 'eleventh' and'twelveth', there is a nice switch statement to deal with that, the rest will be easy.
|
|
|
|
|
Please give me some more detail or link to that article. Thanks
Syed Shahid Hussain
|
|
|
|
|
tell me more friend. I am waiting.
Please
leppie wrote: Search this messageboard for 'eleventh' and'twelveth'
What do you mean by that
Thanks
Syed Shahid Hussain
|
|
|
|
|
Hello friend
Syed Shahid Hussain wrote: I am waiting.
No need. I'm working on it, and I'll post the code when I'm finished. Already half the way.
Regards
|
|
|
|
|
Hello friend.
Here is your code. I hope you like it;).
It consists of 3 methods. You call the ToLiteral() method and supply it with the string you want to parse. It will subsequently call the other two methods to retreive the literals and the segments names. Forgive me for the poor comment -never been good in commenting-. I included a button click even handler to show you how to test for output and how to use the ToLiteral() method.
private void TestButton_Click(object sender, EventArgs e)
{
MessageBox.Show("4\n" + ToLiterals("4"));
MessageBox.Show("57\n" + ToLiterals("57"));
MessageBox.Show("209\n" + ToLiterals("209"));
MessageBox.Show("8734\n" + ToLiterals("8734"));
MessageBox.Show("24567\n" + ToLiterals("24567"));
MessageBox.Show("973654\n" + ToLiterals("973654"));
MessageBox.Show("2315736\n" + ToLiterals("2315736"));
MessageBox.Show("27065154\n" + ToLiterals("27065154"));
MessageBox.Show("827464876\n" + ToLiterals("827464876"));
MessageBox.Show("1675376283\n" + ToLiterals("1675376283"));
}
private string ToLiterals(string Input)
{
String Output = "";
while (Input.Length > 0)
{
if (Input[0] == '0')
{
Input = Input.Remove(0, 1);
Output += "And ";
continue;
}
if (Input.Length % 3 != 2)
{
Output += ConvertChar(Input[0].ToString());
if (Input.Length % 3 == 0 && Input.Length > 2)
Output += "Hundred ";
else
Output += GetSegment(Input.Length / 3);
Input = Input.Remove(0, 1);
continue;
}
else
{
if (Input[0] == '1')
{
Output += ConvertChar(Input.Substring(0, 2));
}
else
{
Output += ConvertChar(Input[0] + "0");
Output += ConvertChar(Input[1].ToString());
}
Output += GetSegment(Input.Length / 3);
Input = Input.Remove(0, 2);
}
}
return Output;
}
private string GetSegment(int seg)
{
switch (seg)
{
case 1: { return "Thousand "; }
case 2: { return "Million "; }
case 3: { return "Billion "; }
case 4: { return "Trillion "; }
default: { return ""; }
}
}
private string ConvertChar(string ToConvert)
{
switch (ToConvert)
{
case "1": { return "One "; }
case "2": { return "Two "; }
case "3": { return "Three "; }
case "4": { return "Four "; }
case "5": { return "Five "; }
case "6": { return "Six "; }
case "7": { return "Seven "; }
case "8": { return "Eight "; }
case "9": { return "Nine "; }
case "10": { return "Ten "; }
case "11": { return "Eleven "; }
case "12": { return "Twelve "; }
case "13": { return "Thirteen "; }
case "14": { return "Fourteen "; }
case "15": { return "Fifteen "; }
case "16": { return "Sixteen "; }
case "17": { return "Seventeen "; }
case "18": { return "Eighteen "; }
case "19": { return "Nineteen "; }
case "20": { return "Twenty "; }
case "30": { return "Thirty "; }
case "40": { return "Fourty "; }
case "50": { return "Fifty "; }
case "60": { return "Sixty "; }
case "70": { return "Seventy "; }
case "80": { return "Eighty "; }
case "90": { return "Ninety "; }
default: { return ""; }
}
}
PS.
It took me about 35mins to write and test the code. It may need some adjustments, but it should give you a good start.
Regards
|
|
|
|
|
Hi
So so thanks. I am so happy that you has given me the code and spend your time on me. I'll use it and send u feedback. Thank you very much.
(I cant imagine that some people are kind enough that they spend their precious time for others. I really appreciate you. I dont have words to thank U. Its my heart sound. By heart thanks alot. And dont mind if u dont like my talks. I am a simple boy and dont let any thing close in my heart, I say it at the spot.)
God Bless You.
Keep messaging,
Your friend
Syed Shahid Hussain
|
|
|
|
|
Hello
I'm always happy to help you .
See you soon on the forum.
Regards
|
|
|
|
|
Thanks friend,
Your code is so logical and it took my two hrs. for understanding it. How your made the logic in just 35 min. You are a true programmer. The code meet all my requirements and I'll use it in my Data Base program "as it is" without any changing. So thanks and so nice of you.
God Bless You
"If u read this plz send me your e-mail address."
Bye
Syed Shahid Hussain
|
|
|
|
|
Well a switch is a manual and less elegant way of doing this.
A preferred way is having all the digit equivalents in a string table, and then having the conjuntion operators in another one, and a mapping list for mapping the info. I will try to post some code on it, using the neural approach that i did 6 years back.
Excelsior
Arjun Bahree
"By The Might of Mjolnir"
I Came! I Coded! I Conquered!
|
|
|
|
|
If you find code send me.
Syed Shahid Hussain
|
|
|
|
|
Hi
I have a string in format "21.05.2004" pleas tell me how to convert it to DataTime format.All time i get InvalidDataException.Pleas help me if you can.
when i want to read something good just seat and type it
|
|
|
|
|
DateTime.Parse ???
Make sure the culture is set correctly for you date format also.
only two letters away from being an asset
|
|
|
|
|
How to change the culture ???
when i want to read something good just seat and type it
|
|
|
|
|
System.Globalization.CultureInfo culture = new System.Globaliztion.CultureInfo("ru-RU"); // Russian
DateTime dt = ConvertTo.DateTime("21.05.2004",culture);
msdn site
|
|
|
|
|
Supper thank's
when i want to read something good just seat and type it
|
|
|
|
|
The System.Guid.NewGuid( ) method seems to have returned duplicate GUIDs, two days in a roll.
Is it possible? Is there any related .NET (1.0 or 1.1) bug reported for this problem?
|
|
|
|
|
|
Hi,could you have code or link to code
For accessing Scheduled Task (windows) created by or modified by the Scheduled Task wizard.
|
|
|
|
|
I am developing windows application in .NET 1.1 using C#. I have developed a custom control for text editing in my application. Whenever i drop that control from toolbox to the form, it does not show the control on form on design time. When I run thaat form, it works pretty fine and it shows that control at run time. But at design time, the Visual Studio is not showing the control. What is the Problem that the control is not shoiwn at design time?
Thanks,
Sandeep S. Sekhon
|
|
|
|
|
If you have something in the design of the control that you do with some variable code then this occurs. For example you may be showing something that the control can only reach when the executable just runs. Something which can only have an appropriate value in runtime etc. Look for such things. You most probably have some code in control's initialize method.
|
|
|
|
|
But running the application for one time, I closed the Visual Studio. I again opened that same application, but this time the control was shown on the form.
Thanks,
Sandeep S. Sekhon
|
|
|
|