我试图将光标锁定到窗体中,这是一个鼠标锁定器应用程序,我试图处理光标,以便它们将Cursor.Clip解锁时重置它.
到目前为止,我有:
Cursor.Clip = new Rectangle(x +8, y +30, Size.Width -16, Size.Height -38);
Run Code Online (Sandbox Code Playgroud)
这很好.
但我无法弄清楚当它们解锁时如何清除它.我试过Cursor.Dispose();但是那不起作用.
有任何想法吗?谢谢.
我们在JasperReports 3.7.0中使用了虚拟程序,以避免一些大型查询耗尽内存。在该主题上找到了一篇有用的文章,并且在《 JasperReports终极指南》中对虚拟器进行了简要描述,但这仅仅是一个开始。我试图找出哪种虚拟机是理想的,并选择了一种虚拟机,如何调整配置参数。任何人都可以在这个话题上提供一些智慧吗?
沃尔特·吉列特
我只是想了解为什么我不能在C#上创建受保护的枚举?
编译器拒绝接受
有谁知道为什么会这样?
虽然网上有一些教程,但我仍然不知道为什么它不能正确打印多个页面.我究竟做错了什么?
public static void printTest()
{
PrintDialog printDialog1 = new PrintDialog();
PrintDocument printDocument1 = new PrintDocument();
printDialog1.Document = printDocument1;
printDocument1.PrintPage +=
new PrintPageEventHandler(printDocument1_PrintPage);
DialogResult result = printDialog1.ShowDialog();
if (result == DialogResult.OK)
{
printDocument1.Print();
}
}
static void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
{
Graphics graphic = e.Graphics;
SolidBrush brush = new SolidBrush(Color.Black);
Font font = new Font("Courier New", 12);
e.PageSettings.PaperSize = new PaperSize("A4", 850, 1100);
float pageWidth = e.PageSettings.PrintableArea.Width;
float pageHeight = e.PageSettings.PrintableArea.Height;
float fontHeight = font.GetHeight();
int startX = 40; …Run Code Online (Sandbox Code Playgroud) 如下面所示的代码,我想从OracleParameter对象中获取值.它的数据类型是datetime.
...
Dim cmd As New OracleCommand("stored_proc_name", cnObject)
cmd.Parameters.Add("tran_date_out", OracleDbType.Date, ParameterDirection.Output)
...
cmd.ExecuteNonQuery()
...
Dim tranDate As Date
tranDate = cmd.Parameters("tran_date_out").Value
Run Code Online (Sandbox Code Playgroud)
当我为tranDate变量赋值时,我收到一个错误.但如果我编码如下,我只得到日期.
tranDate = CDate(cmd.Parameters("tran_date_out").Value.ToString)
Run Code Online (Sandbox Code Playgroud)
那么如何才能获得tranDate变量的日期和时间值?
我刚刚开始使用Moq ver(3.1)并且我已经阅读了博客,而不是......不管怎样......我想直到你弄脏你的手你才会学到:)
好的,这是我正在测试...
var newProduct = new Mock<IPartialPerson>();
newProduct.SetupGet(p => p.FirstName).Returns("FirstName");
newProduct.SetupGet(p => p.MiddleName).Returns("MiddleName");
newProduct.SetupGet(p => p.LastName).Returns("LastName");
newProduct.SetupGet(p => p.EmailAddress).Returns("EmailAddress@hotmail.com");
newProduct.SetupGet(p => p.UserID).Returns("UserID");
//mock Escort repository
var mockEscortRepository = new Mock<IEscortRepository>();
mockEscortRepository.Setup(p => p.LoadAllEscorts())
.Returns(newProduct.Object); //error
Run Code Online (Sandbox Code Playgroud)
错误1'Moq.Language.IReturns> .Returns(System.Collections.Generic.List)'的最佳重载方法匹配有一些无效的参数
错误2参数'1':无法从'App.Model.Interface.IPartialPerson'转换为'System.Collections.Generic.List'
public interface IPartialPerson
{
string FirstName { get; }
string MiddleName { get; }
string LastName { get; }
string EmailAddress { get; }
string FullName { get; }
string UserID { get; }
}
public interface IEscortRepository
{
List<PartialPerson> LoadAllEscorts(); …Run Code Online (Sandbox Code Playgroud) 我写了以下代码:
var threaddatatable = new System.Threading.Thread(update);
threaddatatable.Start(dt);
update(datatable dt)
{
}
Run Code Online (Sandbox Code Playgroud)
但我收到这些错误:
System.Threading.Thread.Thread(System.Threading.ThreadStart)的最佳重载方法匹配有一些无效的参数
和
参数1无法从"方法组"转换为System.Threading.ThreadStart
如何将我的update方法分配给我的线程?
我在这个msdn页面上看了关于与Monitor.Pulse()进行线程同步的例2 .
创建Cell对象并将其传递给生产者和使用者对象.
Cell cell = new Cell( );
CellProd prod = new CellProd(cell, 20);
CellCons cons = new CellCons(cell, 20);
Run Code Online (Sandbox Code Playgroud)
为这两者中的每一个创建一个线程
Thread producer = new Thread(new ThreadStart(prod.ThreadRun));
Thread consumer = new Thread(new ThreadStart(cons.ThreadRun));
Run Code Online (Sandbox Code Playgroud)
ThreadRun在每种情况下都是一个循环,它根据消费者/生产者调用Cell.ReadFromCell()或Cell.WriteToCell().例如,生产者这样做
public void ThreadRun( )
{
for(int looper=1; looper<=quantity; looper++)
cell.WriteToCell(looper); // "producing"
}
Run Code Online (Sandbox Code Playgroud)
我不明白的是,在每种方法中,它们都以a开头
lock(this)
Run Code Online (Sandbox Code Playgroud)
并且因为它是同一个Cell对象(即上面的锁定语句中的'this')传递给两者,我认为一次只有一个线程可以在这段代码中.然而,从它后面的Monitor.Pulse()和Monitor.Wait()代码看起来两个线程同时在这些部分中.如果有一个锁并且点击一个Monitor.Wait()那么另一个线程永远不会是Pulse,因为它被阻塞等待锁定.
我猜有一个简单的解决方案而且我误解了一些东西,从我运行代码的测试看起来两个线程同时在他们的关键部分,所以锁(这个)不是我做的事情它应该做的印象.
考虑一下我可能控制或不控制的工厂方法,将其传递给另一个类Func<T>:
// this.FactoryMethod is an external dependency passed into this class
// through constructor or property injection assume that it is not null
// but there is no guarantee that it will return a non-null reference.
Func<IModel> FactoryMethod;
public IModel GetPopulatedModel(int state, FileInfo someFile)
{
// Argument validation omitted for brevity...
// This operation could return null.
var model = this.FactoryMethod()
if (model == null)
{
throw new SomeException("Factory method failed to produce a value.");
}
// Safe …Run Code Online (Sandbox Code Playgroud)