|
hy everyone!
we do have a problem:
we coded a webpart which allows searching and printing of document in a document store. you search for files, you are able to display them and you are able to print them.
therefor we wrote a printservice, which fetches the file from the store and sends them to the spooler and printer respectively. that works fine. afterwords we update the database to set some fields, indicating the file was already printed.
when using a little amount of files it works file, but the bigger the collection of file is, the more problems appear. meaning, when selecting around 100 files with around 1 MB each, a thread abort exception is thrown. if there are just 40 files, no exception is thrown.
and to complicate the situation: if you repeat printing the same files lets say for 10 times, it works in lets say 7 tries and fails in 3 tries. sometimes it even works in all tries or it fails more often. its like guessing numbers in a lottery.
but it does not throw the thrad abort exception during printing, it throws the exception when returning to the code of the webpart where the printing was invoked at. meaning we wrote a printbuttonclick event-function which invokes the printservice with the file ids, and some other properties. and when returning the exception is thrown.
we tried to change the timeout of the printservice indefinite (-1), we also tried to change the code to get as much performance as possible, we also did a lot of garbage collection etc. but we can't get rid of this exception.
we also have already been googling for this incident, but nothing really solved our problem. we were just able to send more files until it is likely to be thrown.
printing around 100 files could take up to 1-2 minutes, so i guess maybe this could take to long and the thread times out when returning.
does anyone have an idea of
1) where to start to get an idea how to get rid of this error (maybe a page of hints we haven't already been to etc.)
2) how to get rid of this exception. maybe one of you has already encountered anything similar.
thanks for any hints and ideas.
if you do need some further infos for understanding or to get an idea of how to solve it, just feel free to ask.
thanks!
stephan.
|
|
|
|
|
The only thing that the ThreadAbortException is used for, is aborting threads. That is done by calling the Abort method of a Thread, which then throws the exception in the thread in order to abort it.
So, are you aborting any thread?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
nope, i am not aborting any thread.
i forgot to add an important info: sharepoint is located on two servers, meaning there is a loadbalancing installed using two servers. could it be, the task is switched to the other server when returning?
meaning when starting the printing from server A to sharepoint it looks like as if the server is very busy and when returning it is switched to server B, but there is not thread active so it thinks it is aborted?
that's an idea which I had when talking to some other guys.
|
|
|
|
|
For example, lets say I have 500 proxies and I wanted to check them all. How could I split those up into a random amount of threads(User inputted) and check them all at once using multiple threads.
Thanks,
BuckleyInDaHouse.
|
|
|
|
|
You probably can't check them all at once, because you might overload the computer and/or the network.
Start a couple of worker threads, and let them check the proxies one at a time.
If you search for SynchronisedQueue, you will find a class that I wrote a while back. You can use it to let the threads get one task at a time from a common queue, and to let all the threads return the results to the main thread.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi
I have written the following asp.net page and creating the xml file through a method everything is fine it is creating the file but i have a problem. May be you can help for that. it is about the xml file output when it created it showing TABLE and TABLE1 as node in xml how i can change it to meaningful name. My Code is as follows. XML file is at the bottom of the code
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Xml;
using System.IO;
public partial class _Default : System.Web.UI.Page
{protected void Page_Load(object sender, EventArgs e){
GetEmployees("London");
}
public static void GetEmployees(string City){
//String sConnection = "server=HTCWEBDEMO;database=hometrust;user id=ht_admin;password=htc_tr!st";
String sConnection = "server=ZAFAR-PC\\SQLEXPRESS;Integrated Security=SSPI;database=northwind";
SqlConnection mySqlConnection = new SqlConnection(sConnection);
mySqlConnection.Open();
// Get the same data through the provider.
//string mySQLStatement = "SELECT Title,FirstName,LastName,PhoneNumber,Faxnumber, email from contactlist where TeamName='" + TeamName +"'; select FirstName, LastName from contactlist where TeamMorty ='True' and teamname='" + TeamName + "';";
string mySQLStatement = "SELECT FirstName,LastName,Title,City from employees where city= '" + City + "';select FirstName, LastName from employees where city='" + City + "';";
//SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter(mySQLStatement, sConnection);
SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter(mySQLStatement, sConnection);
DataSet myDataSet2 = new DataSet();
myDataSet2.DataSetName = "Contacts";
mySqlDataAdapter.Fill(myDataSet2);
// Write data to files: data1.xml and data2.xml for comparison.
myDataSet2.WriteXml("c:/temp/ContactList.xml");
mySqlConnection.Close();
}
}
XML FILE OUTPUT
<?xml version="1.0" standalone="yes" ?>
- <Contacts>
- <Table>
<FirstName>Steven</FirstName>
<LastName>Buchanan</LastName>
<Title>Sales Manager</Title>
<City>London</City>
</Table>
- <Table>
<FirstName>Michael</FirstName>
<LastName>Suyama</LastName>
<Title>Sales Representative</Title>
<City>London</City>
</Table>
- <Table>
<FirstName>Robert</FirstName>
<LastName>King</LastName>
<Title>Sales Representative</Title>
<City>London</City>
</Table>
- <Table>
<FirstName>Anne</FirstName>
<LastName>Dodsworth</LastName>
<Title>Sales Representative</Title>
<City>London</City>
</Table>
- <Table1>
<FirstName>Steven</FirstName>
<LastName>Buchanan</LastName>
</Table1>
- <Table1>
<FirstName>Michael</FirstName>
<LastName>Suyama</LastName>
</Table1>
- <Table1>
<FirstName>Robert</FirstName>
<LastName>King</LastName>
</Table1>
- <Table1>
<FirstName>Anne</FirstName>
<LastName>Dodsworth</LastName>
</Table1>
</Contacts>
|
|
|
|
|
|
Nice reply in the other forum
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
In code below Line
m_Grid.RowCount = 1000000;
takes 8 seconds.
How to speed it up ?
Andrus.
using System;
using System.Windows.Forms;
using System.Collections.Generic;
class test
{
[STAThreadAttribute()]
public static void Main()
{
Application.Run(new VirtualModeForm());
}
}
class VirtualModeForm : Form
{
private List<DataObject> m_Data = new List<DataObject>();
private List<bool> m_Visited = new List<bool>();
DataGridView m_Grid = new DataGridView();
public VirtualModeForm()
{
Controls.Add(m_Grid);
m_Grid.CellValueNeeded += OnCellValueNeeded;
InitData();
InitGrid();
}
private void InitData()
{
for (int i = 0; i < 1000001 + 1; i++)
{
m_Visited.Add(false);
DataObject obj = new DataObject();
obj.Id = i;
obj.Val = 2 * i;
m_Data.Add(obj);
}
}
private void InitGrid()
{
m_Grid.Dock = DockStyle.Fill;
m_Grid.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCellsExceptHeader);
m_Grid.VirtualMode = true;
m_Grid.ReadOnly = true;
m_Grid.ColumnCount = 108;
m_Grid.RowCount = 1000000;
}
private void OnCellValueNeeded(object sender, DataGridViewCellValueEventArgs e)
{
m_Visited[e.RowIndex] = true;
if (e.ColumnIndex == 0)
{
e.Value = m_Data[e.RowIndex].Id;
}
else if (e.ColumnIndex == 1)
{
e.Value = m_Data[e.RowIndex].Val;
}
else if (e.ColumnIndex == 2)
{
Random rand = new Random();
e.Value = rand.Next();
}
}
}
public class DataObject
{
private int m_Id;
private int m_Val;
public int Val
{
get { return m_Val; }
set { m_Val = value; }
}
public int Id
{
get { return m_Id; }
set { m_Id = value; }
}
public int Id1 { get; set; }
public int Id2 { get; set; }
public int Id3 { get; set; }
public int Id4 { get; set; }
public int Id5 { get; set; }
public int Id6 { get; set; }
public int Id7 { get; set; }
public int Id8 { get; set; }
public int Id9 { get; set; }
public int Id10 { get; set; }
public int Id11 { get; set; }
public int Id12 { get; set; }
public int Id13 { get; set; }
public int Id14 { get; set; }
public int Id15 { get; set; }
public int Id16 { get; set; }
public int Id17 { get; set; }
public int Id18 { get; set; }
public int Id19 { get; set; }
public int Id20 { get; set; }
public int Id21 { get; set; }
public int Id22 { get; set; }
public int Id23 { get; set; }
public int Id24 { get; set; }
public int Id25 { get; set; }
public int Id26 { get; set; }
public int Id27 { get; set; }
public int Id28 { get; set; }
public int Id29 { get; set; }
public int Id31 { get; set; }
public int Id32 { get; set; }
public int Id33 { get; set; }
public int Id34 { get; set; }
public int Id35 { get; set; }
public int Id36 { get; set; }
public int Id37 { get; set; }
public int Id38 { get; set; }
public int Id39 { get; set; }
public int Id310 { get; set; }
public int Id311 { get; set; }
public int Id312 { get; set; }
public int Id313 { get; set; }
public int Id314 { get; set; }
public int Id315 { get; set; }
public int Id316 { get; set; }
public int Id317 { get; set; }
public int Id318 { get; set; }
public int Id319 { get; set; }
public int Id320 { get; set; }
public int Id321 { get; set; }
public int Id322 { get; set; }
public int Id323 { get; set; }
public int Id324 { get; set; }
public int Id325 { get; set; }
public int Id326 { get; set; }
public int Id327 { get; set; }
public int Id328 { get; set; }
public int Id329 { get; set; }
public int Id401 { get; set; }
public int Id402 { get; set; }
public int Id403 { get; set; }
public int Id404 { get; set; }
public int Id405 { get; set; }
public int Id406 { get; set; }
public int Id407 { get; set; }
public int Id408 { get; set; }
public int Id409 { get; set; }
public int Id4010 { get; set; }
public int Id4011 { get; set; }
public int Id4012 { get; set; }
public int Id4013 { get; set; }
public int Id4014 { get; set; }
public int Id4015 { get; set; }
public int Id4016 { get; set; }
public int Id4017 { get; set; }
public int Id4018 { get; set; }
public int Id4019 { get; set; }
public int Id4020 { get; set; }
public int Id4021 { get; set; }
public int Id4022 { get; set; }
public int Id4023 { get; set; }
public int Id4024 { get; set; }
public int Id4025 { get; set; }
public int Id4026 { get; set; }
public int Id4027 { get; set; }
public int Id4028 { get; set; }
public int Id4029 { get; set; }
public int Id4031 { get; set; }
public int Id4032 { get; set; }
public int Id4033 { get; set; }
public int Id4034 { get; set; }
public int Id4035 { get; set; }
public int Id4036 { get; set; }
public int Id4037 { get; set; }
public int Id4038 { get; set; }
public int Id4039 { get; set; }
public int Id40310 { get; set; }
public int Id40311 { get; set; }
public int Id40312 { get; set; }
public int Id40313 { get; set; }
public int Id40314 { get; set; }
public int Id40315 { get; set; }
public int Id40316 { get; set; }
public int Id40317 { get; set; }
public int Id40318 { get; set; }
public int Id40319 { get; set; }
public int Id40320 { get; set; }
public int Id40321 { get; set; }
public int Id40322 { get; set; }
public int Id40323 { get; set; }
public int Id40324 { get; set; }
public int Id40325 { get; set; }
public int Id40326 { get; set; }
public int Id40327 { get; set; }
public int Id40328 { get; set; }
public int Id40329 { get; set; }
}
Andrus
|
|
|
|
|
If you're already using virtual mode, why set the row count so high. Try a smaller value like 100. When additional rows are needed, CellValueNeeded should provide them from a store like datatable, array etc.
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
Fake Rowcount causes the following issues:
1. It is not possible to see more rows: you can navigate only between first 100 rows. No way to go to row number 101.
2. Buttor in vertical scrollbar does not show real position in table. For real rowcount, button indicates visually real position: in the start, in middle or in end of table.
So it is impossible to use fake rowcount.
Andrus
|
|
|
|
|
Sorry, wrote that in a hurry. Rowcount is the actual amount which is used to define scroll size. If you have wired CellValueNeeded correctly, it should work fine.
Have you checked that CellValueNeeded is actually used and is it called (several times) when you set the rowcount. Another thing is that you have automatic sizes for columns. That may slow this quite a lot. Try commenting it out and test if any change.
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
Mika,
thank you for reply.
Tried tried the following:
1. OnCellValueNeeded is not called: F11 steps to next line after 8 sec delay.
Debug output window shows a lot of messagers "skipping over non-user code". Delay seems to occur after those messages are output.
2. I removed m_Grid.AutoResizeColumns line and tried with DataGridViewAutoSizeColumnsMode.None
Delay still occurs.
I'm wondering why number or rows affects to this delay. VirtualMode must be designed to avoid this.
Is it possible to use other control to create editable virtual grid ? I looked SourceGrid in http://www.devage.com/[^]
but it last update was a year ago so it seems not maintained.
Those grids are used frequently in my application in UI. Data for visibla part of a grid grid is retrieved from database for 4 seconds due to virtualization. It is not reasonable to force user to wait 8 seconds for a grid to render.
Any idea how to fix this ?
Andrus
|
|
|
|
|
Hi,
do some research on DataGridView.VirtualMode, that is the official
way to handle insane amounts of data in a reasonable time.
I haven't used it myself yet, so I won't be able to explain from experience.
|
|
|
|
|
Lyc,
as you see from my sample it already uses VirtualMode.
The issue is that increasing number of rows decreases RowCount setting speed.
This should not happen.
Andrus
|
|
|
|
|
Hi,
I suggest you study some examples, and observe your code as to what exactly
is going on. As in: how many ValueNeeded events do fire, and how many
items are visible at one time. If there is a mismatch, then that is the
problem. The basic concept is the DGV should only fire ValueNeeded for
items that have to be drawn.
BTW are you sure you want over 100 columns? and all those get/set properties?
it does not look right.
Also I don't like the two lists of properties, the only data you should
need is a list of items. Avoid redundancy!
|
|
|
|
|
Luc,
Thank you. MSDN has DataGridView_Samples.zip which contains two VirtualMode grid samples and a doc file covering VirtualMode a bit.
Part of samples from this file are also duplicated in MSDN doc code samples.
MSDN forums contains also some few messages about VirtualMode.
There is also a Chris Cells book. The sample code presented here is modified sample from this book.
My code is based on this information.
I have looked first 100 pages returned from google search.
I havent found any other information about DataGridView VirtualMode.
Pressing F11 in RowCount moves to next line after delay. So OnCellValueNeeded method not any other lines in my code are not called.
In real application I have wide Product tables which can contain 100 columns. They appear fine in wide LCD screen. Reducing number of columns to 50 causes also long delay.
I'm sorry for a bad sample. Below is minimal code to reproduce
8 sec delay issue.
using System;
using System.Windows.Forms;
class Test
{
public static void Main()
{
Application.Run(new VirtualModeForm());
}
}
class VirtualModeForm : Form
{
DataGridView grid = new DataGridView();
public VirtualModeForm()
{
Controls.Add(grid);
grid.VirtualMode = true;
grid.ColumnCount = 108;
grid.RowCount = 1000000;
}
}
Andrus
|
|
|
|
|
Hi Andrus,
I did a little experiment with your code. Observations:
- time elapsed is proportional to number of rows;
- time elapsed heavily depends (not proportional) on number of columns
- setting RowCount first is a lot faster.
Conclusions:
1) the DGV seems to create objects for all the cells right from
the start, and creating 108 million objects is bound to take a couple
of seconds.
2) for unknown reasons RowCount-first is faster
BTW: you should not add the grid to Controls before it has been set up.
|
|
|
|
|
Luc,
2) for unknown reasons RowCount-first is faster
Thank you very much. You are genious.
I tried this in my applicaton and this eliminates RowCount delay.
Now there is only 3 sec delay which is caused by reading first two pages to cache like in MSDN sample.
There is also SELECT COUNT(*) FROM mytable command but this seems not to cause any delay.
the DGV seems to create objects for all the cells right from
the start, and creating 108 million objects is bound to take a couple
108 millions of objects should take visible in Task Manager amout of memory. Task Manager memory (working set) does not show significat memory consumption.
So I think that 108 million of objects are not created.
Maybe this is related to sililar issue which posted here and in MS product feedback and which does not have any solution:
Steps to reproduce:
1. Run code below
2. Double click in grid header in separation line between columns 1 ja 2
Observed:
CPU usage goes to 100% for a long time.
using System;<br />
using System.Windows.Forms;<br />
using System.Collections.Generic;<br />
<br />
class test {<br />
[STAThreadAttribute()]<br />
public static void Main() {<br />
Application.Run(new VirtualModeForm());<br />
}<br />
}<br />
<br />
class VirtualModeForm : Form {<br />
private List<DataObject> m_Data = new List<DataObject>();<br />
private List<bool> m_Visited = new List<bool>();<br />
DataGridView m_Grid = new DataGridView();<br />
public VirtualModeForm() {<br />
Controls.Add(m_Grid);<br />
m_Grid.CellValueNeeded += OnCellValueNeeded;<br />
InitData();<br />
InitGrid();<br />
}<br />
<br />
private void InitData() {<br />
for (int i = 0; i < 1000001 + 1; i++) {<br />
m_Visited.Add(false);<br />
DataObject obj = new DataObject();<br />
obj.Id = i;<br />
obj.Val = 2 * i;<br />
m_Data.Add(obj);<br />
} }<br />
<br />
private void InitGrid() {<br />
m_Grid.Dock = DockStyle.Fill;<br />
m_Grid.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCellsExceptHeader);<br />
m_Grid.VirtualMode = true;<br />
m_Grid.ReadOnly = true;<br />
m_Grid.ColumnCount = 3;<br />
m_Grid.Rows.Add();<br />
m_Grid.Rows.AddCopies(0, 1000000);<br />
}<br />
<br />
private void OnCellValueNeeded(object sender, DataGridViewCellValueEventArgs e) {<br />
<br />
m_Visited[e.RowIndex] = true;<br />
if (e.ColumnIndex == 0) {<br />
e.Value = m_Data[e.RowIndex].Id;<br />
} else if (e.ColumnIndex == 1) {<br />
e.Value = m_Data[e.RowIndex].Val;<br />
} else if (e.ColumnIndex == 2) {<br />
<br />
Random rand = new Random();<br />
e.Value = rand.Next();<br />
}<br />
}<br />
}<br />
<br />
public class DataObject {<br />
private int m_Id;<br />
private int m_Val;<br />
<br />
public int Val {<br />
get { return m_Val; }<br />
set { m_Val = value; }<br />
}<br />
<br />
public int Id {<br />
get { return m_Id; }<br />
set { m_Id = value; }<br />
}<br />
}
How to fix this ?
BTW: you should not add the grid to Controls before it has been set up.
I tried it but this does not to affect to speed at all.
My base class is created using Winforms designer which adds grid in form constructur. If I modify this code manually changes are lost when designer re-creates code.
Code sample of this is below.
Questions:
1. Why I should not add grid before setting ?
2. How to add grid only after it has set without modifying designer generated grid code manually to code below? I need to use subclassed form because main form contains generic type parameter and Winforms designer does not allow to design form with generic.
using System;<br />
using System.Windows.Forms;<br />
<br />
class Test<br />
{<br />
public static void Main()<br />
{<br />
Application.Run(new VirtualModeForm<Customer>());<br />
}<br />
}<br />
<br />
class VirtualModeForm<T> : BaseForm<br />
{<br />
public VirtualModeForm()<br />
{<br />
grid.VirtualMode = true;<br />
grid.RowCount = 1000000;<br />
grid.ColumnCount = 108;<br />
}<br />
}<br />
<br />
class Customer { }<br />
<br />
class BaseForm : Form<br />
{<br />
internal BaseForm()<br />
{<br />
InitializeComponent();<br />
}<br />
<br />
void InitializeComponent()<br />
{<br />
grid = new DataGridView();<br />
Controls.Add(grid);<br />
}<br />
protected DataGridView grid;<br />
}
Andrus
|
|
|
|
|
i am making an application which requires to call the telephone or mobile.
and i don't how to do this can any one pls help me.............
|
|
|
|
|
What research have you done? What products are you evaluating? What services have you checked out? What does the client require? Landline + mobile? How do you honestly expect anyone to answer effectively if you can't provide even a small amount of detail?
Bar fomos edo pariyart gedeem, agreo eo dranem abal edyero eyrem kalm kareore
|
|
|
|
|
The last time I did that I used a MODEM.
|
|
|
|
|
this is the first time I'm using message queue, but when trying to crate a message queue it says that message queue is not installed, do i have to install it separately or is it because my local machine is not a server .
|
|
|
|
|
To use message queuing the machine has to be added to an Active Directory domain, and MessageQueuing must be installed at the machine. This is to be found under "Add/remove windows components"
|
|
|
|
|
I'm working on a project where my application (in .net) should communicate with a java-application through MSMQ. By using BinaryMessageFormatter the java application could not deserialize the message, but this worked fine when using XmlMessageFormatter.
The problem is that this java application posts back an XML to the message queue, but i can't read this in any way.
I have the following code:
1 using (MessageQueue mq = new MessageQueue(".\\testQueue"))
2 {
3 mq.Formatter = new XmlMessageFormatter(new Type[] { typeof(string), typeof(XmlDocument), typeof(XmlElement), typeof(XmlDataDocument), typeof(XmlNode) });
4
5 using (Message msg = mq.Receive())
6 {
7 try
8 {
9 object o = msg.Body;
10 Console.WriteLine(o as string);
11 }
12 catch (Exception ex)
13 {
14 Console.WriteLine("Error: " + ex.Message);
15 }
16 finally
17 {
18 Console.ReadKey(true);
19 }
20 }
21 }
I just get an error message "There is an error in XML document (2,1)". Is there any way to "read the raw content" of a message, or any other way to get the content of the message?
The XML in the incoming queue starts like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<StatusSMSMessage xmlns="http://www........./specs/schemas/smsgw/StatusSMSMessage.xsd" mtMessageId="minimalMessage1"><DestinationAddress>
Do I have to implement message queuing from the Windows COM-library? In case; how to do this in .net?
|
|
|
|